Elastic · Report #1168528
Improper authorization on `/api/as/v1/credentials/` allows any App Search user to access all API keys and escalate privileges
How it was found
Summary
Hello team, I hope you're doing well! App Search has a credentials page located at /as#/credentials that lists all the API keys a user has access to, if any. That same page will 404 for users with Analyst or Editor role. This is all working as intended, however there is also an API endpoint to query that same data at /api/as/v1/credentials/ and this will list all existing API keys for any authenticated user regardless of their App Search role.
Steps to reproduce
I'm going to use the cloud environment for the reproduction
Preparation
- Log in App Search with the admin (
elastic) user and go to theUsers & rolespage (/as#/role-mappings/) - Click
Add mapping - In the
Attribute valuefield enterh1-repro - In the
Rolebox selectAnalyst - In the
Engine AccessselectLimited Engine Access, no need to select any engine- We now have created the most limited role possible
- Log in Kibana with the admin (
elastic) user and go to theStack Management>Userspage (/app/management/security/users/) - Click
Create user - In the
Usernamefield enterhi-repro - Set any password you like and then click
Create user
Reproduction
- Log in App Search with the
h1-reprouser - Navigate to
/as#/role-mappings/and observe that it's a 404 because you don't have access to this page - Navigate to
/api/as/v1/credentials/and observe that you have access to all the API keys
Impact
Privilege escalation. The default App Search install has a Private API Key with read/write access to all engines. If a Private Admin Key has been created before. the attacker can use it to create new API keys or delete existing ones.