How JS Analysis Led to PII Disclosure
An API key was hard-coded in a JavaScript file, and it allowed access to GraphQL operations that lacked authorization checks. An attacker could use the key to query user details by phone number and list all phone numbers stored in the database.
medium.com
Published on medium.com
Hi everyone, this is one of my pentest stories about a client had rolled out a platform which allowed users to apply for a credit card. This pentest was done a week before the launch of the product.
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 API key was hard-coded in client-side JavaScript and the GraphQL operations did not enforce authorization.
What the attacker needed
Access to the web application; no authentication needed
The fix
The client removed the vulnerable operations just before launch, but the proper fix would be to remove the hard-coded key and enforce authorization on GraphQL operations.
How it was found
- Start the credit card application flow and inspect all response headers for the X-API-Key.
- Check browser storage for the key.
- Search JavaScript files and find the key hard-coded.
- Use GraphQL introspection to list all queries and mutations.
- Invoke the exportBulkData operation with a phone number to retrieve user details.
- Invoke another query to fetch all phone numbers from DynamoDB.
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 secret key was left inside a file that every visitor's browser downloads, so anyone could find it. That key let the person talk to the server's data interface, which did not check who was asking. As a result, personal information like phone numbers could be read by anyone with the key.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.