NoSQL Injection in Plain Sight
The application's API endpoints accepted a NoSQL filter parameter that was not properly sanitised, allowing an attacker to use MongoDB operators like 'gt' to retrieve data beyond their own user. By changing the filter, the attacker could access other users' customer information and, on one endpoint, leak PII including email addresses, usernames, password hashes, and phone numbers, including those of an administrator.
Published on kuldeep.io
This article is going to be about my recent discovery on Synack Red Team which was a NoSQL injection.
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 application directly evaluated user-supplied filter expressions without restricting which operators could be used, allowing injection of arbitrary MongoDB query operators.
Impact
An authenticated attacker could access other users' basic information and, on one endpoint, leak PII including email addresses, usernames, password hashes, and phone numbers, including those of an administrator.
What the attacker needed
Authenticated access to the application; knowledge of the $filter parameter
How it was found
- Log in to the application and intercept the request to the /api/[CLIENT_NAME]/Customers endpoint.
- Observe the $filter parameter containing a NoSQL query with the 'eq' operator.
- Modify the $filter parameter to use the 'gt' operator, e.g., $filter=(id gt 0).
- Send the request and observe that data for other users is returned.
- Find other endpoints using the $filter parameter, such as /api/[CLIENT_NAME]/CustomerLogins.
- Send the same modified filter to the CustomerLogins endpoint and observe leakage of PII including password hashes.
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 application had a search feature that let users filter data using a special query language. The developer assumed users would only use the simple 'equals' operator, but the system also accepted other operators like 'greater than'. By changing the operator, a user could see data that belonged to other people, including sensitive information like password hashes.
What is IDOR?
One user can read or change another user's data, usually by changing an identifier the server trusts without checking who is asking. One of the most paid bug classes on web programs.