SQL Injection in GraphQL WebSocket Escalated to PII & Document Le
A GraphQL WebSocket endpoint allowed reading and locking documents by ID without checking ownership, and the ID parameter was vulnerable to error-based SQL injection. An attacker could leak document IDs and other users' personal data, then use those IDs to read and lock private legal documents.
Published on medium.com
During a recent engagement on an application designed for managing and customizing legal templates, I discovered a critical vulnerability within a GraphQL WebSocket endpoint. What initially appeared to be an unexploitable Insecure Direct Object Reference (IDOR) was successfully escalated into an Error-Based PostgreSQL…
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 document ID parameter was concatenated into a PostgreSQL query without parameterisation, and the document lookup lacked an ownership check.
Impact
An attacker could read and lock private legal documents belonging to other organisations and leak personal data such as names, addresses, emails and signature IDs.
What the attacker needed
A free account; access to the GraphQL WebSocket endpoint; knowledge of a valid document ID format
How it was found
- Observe the quiet WebSocket connection to the GraphQL endpoint and inspect the client-side JavaScript to find hidden read and lock operations.
- Send a document ID belonging to another test account and confirm the document can be read and locked.
- Replace the numeric ID with random characters and observe a verbose PostgreSQL syntax error mentioning an email column.
- Inject the email column into the ID parameter to trigger a type conversion error that reflects a user's email address.
- Use string concatenation to dump additional columns and document IDs across users.
- Feed the leaked document IDs back into the WebSocket request to read and lock other organisations' documents.
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.
The app lets users open documents by sending an ID number over a WebSocket, a two-way connection between browser and server. The server never checked whether the document belonged to the person asking, and it also put the ID straight into a database query, so specially crafted input made the database reveal other users' details. Together, this let the researcher find secret document IDs and then open documents belonging to other organisations.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.