Skip to content
SQL injection Write-up Intermediate

NoSQL Injection: How I Turned ?search= Into an Admin Oracle

A public search parameter was passed verbatim into Elasticsearch's query_string, letting an unauthenticated attacker inject query syntax to filter and enumerate user records by hidden fields such as email, role, status and private demographics. This bypassed the API's OAuth scope checks, which only guarded returned field values, not query filters.

medium.com

Published on medium.com

Hello friend, I’m Thomas Youssef — and this one is a little different from my usual access control writeups. No role swapping.

Thomas Youssef, on medium.com

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 search parameter was passed directly into Elasticsearch's query_string, and access checks only covered which fields were returned rather than which fields could be used as filters.

Impact

An unauthenticated attacker could enumerate and filter the entire user base by hidden fields including email, admin role, ban status and private demographics, bypassing OAuth scopes and producing targeted lists for phishing or credential stuffing.

What the attacker needed

No authentication; target uses Elasticsearch query_string

The fix

The search input should be passed through a query type such as multi_match that treats it as literal text rather than Lucene syntax.

How it was found

  1. Send a search value using the _exists_ operator to confirm the input is executed as Elasticsearch syntax.
  2. Query the users endpoint filtering by an email domain to enumerate accounts.
  3. Filter by the internal status field to list banned users.
  4. Filter by the role field to list admin accounts.
  5. Filter by scope-protected fields such as first name, revenue and birthday to bypass OAuth scopes.

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 site's search box was wired straight into a database query language, so typing special database syntax instead of a normal word made the database answer questions it should not. The site hid sensitive fields like email from the response, but it still let anyone filter by those fields, so an attacker could count and list users by email domain, admin role or other private attributes without logging in.

What is SQL injection?

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.

Similar reports

View all

Same bug class and techniques, clearest first.

SQL injection

The lesson behind this report.

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.