Lab: Accidental exposure of private GraphQL fields
Source: Dev.to
Lab Overview
The user‑management functions for this lab are powered by a GraphQL endpoint. An access‑control vulnerability allows the API to reveal private credential fields. The goal is to sign in as the administrator and delete the username carlos.
Lab link:
Accessing the GraphQL Endpoint
- Open My account and attempt a login with any credentials.
- The login request is a POST to
/graphqlcontaining a GraphQL mutation withusernameandpassword. - The mutation fails to authenticate, but the request still reaches the GraphQL server.
Introspection
The server has introspection enabled, allowing the full schema to be discovered.
- Intercept the login mutation in your proxy (e.g., Burp Suite).
- Send the intercepted request to the Repeater.
- In the request body, right‑click → GraphQL → Set introspection query.
- Send the request. The response returns the complete schema.
Tip: Use the InQL browser extension to view the schema more conveniently.
Exploiting the Vulnerability
The getUser query contains sensitive fields (username, password). Craft a query to retrieve them:
query {
getUser(id: 1) {
username
password
}
}
Send this query to the /graphql endpoint (e.g., via the Repeater or a GraphQL client). The response reveals the administrator’s username and password.
Solution
- Log in as the administrator using the leaked credentials.
- Delete the user with the username carlos.
The lab is then marked as complete.