Accidental Exposure of Private GraphQL Fields
The GraphQL API exposed a private field that returned user passwords in plaintext, allowing an attacker to obtain credentials for any user, including administrators. By querying the getUser query with a valid user ID, an attacker could retrieve the password and log in as that user.
infosecwriteups.com
Published on infosecwriteups.com
In this lab challenge provided by PortSwigger, the GraphQL API that handles user management functions contains an access control flaw. The GraphQL endpoint inadvertently exposes sensitive fields related to user credentials due to improper access restrictions.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the GraphQL schema did not restrict access to sensitive fields like password, and introspection was enabled, allowing attackers to discover and query the getUser query.
Impact
An attacker could obtain plaintext passwords for any user, including administrators, leading to credential disclosure and privilege escalation, enabling actions such as deleting users or modifying data.
What the attacker needed
Access to the lab environment; Burp Suite with GraphQL extension
How it was found
- Start the lab and observe the GraphQL request in Burp Suite's HTTP history.
- Attempt login with random credentials to generate a login mutation.
- Identify the login mutation in Burp Suite's history and send it to Repeater.
- Execute an introspection query to retrieve the full GraphQL schema.
- Save the queries to the site map and find the getUser query.
- Send the getUser query with id set to 1 to retrieve a user object containing username and password.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A GraphQL API is a way for apps to ask a server for specific data. Here, the server mistakenly allowed anyone to ask for a user's password, which should never be exposed. An attacker could then use that password to log in as that user, even an admin.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.