NoSQL Injection labs

NoSQL Injection (Mongo, Couch, Redis)

What is NoSQL Injection?

NoSQL Injection exploits the lack of sanitization in queries to NoSQL databases like MongoDB, CouchDB or Redis. Operators such as $gt, $ne and $where let you bypass authentication, read arbitrary documents or run server-side JavaScript.

Why practice NoSQL Injection?

The MERN/MEAN stack has pushed MongoDB to the frontline of many APIs. Devs coming from SQL apply parameterization thinking they're safe, but Mongo's native operators open a whole new class of injections. Typical bounties: $500–$5,000 per login bypass.

What will you learn with the NoSQL Injection labs?

You'll learn the dangerous operators ($where, $regex, $gt, $ne, $exists), how to send them via JSON body and via query string parsed by qs/Express, blind techniques with anchored $regex, and how to escalate from auth bypass to takeover by combining with IDOR.

Types of NoSQL Injection we cover

  • Operator injection

    Passing `{"$gt": ""}` instead of a string so the match always succeeds. The classic login bypass on Express + qs parser.

  • $where JS injection

    When `$where` is used with a string containing user input, you run arbitrary JavaScript on the Mongo server.

  • Blind regex

    Using `$regex` with anchors (^, $) to extract characters one by one when there's no direct output.

How do you find and exploit NoSQL Injection?

A practical playbook — from recon to proof of concept.

  1. 1

    Detect operator parsing

    On a JSON login, replace the string value with an object holding an operator. If behavior changes, the backend drops your raw input into the query.

    {"username":"admin","password":{"$ne":null}}
  2. 2

    Bypass authentication

    $gt with an empty string matches any document. Combine it with a known username to log in without a password.

    {"username":"admin","password":{"$gt":""}}
  3. 3

    Inject via query string

    Express + the qs parser turns user[$ne]= into an object with an operator. Useful when the endpoint is GET or urlencoded form data.

    POST /login → username[$ne]=x&password[$ne]=x
  4. 4

    Blind-extract data with $regex

    With no output, anchor a regex and try character by character, watching login OK/KO to reconstruct the secret.

    {"username":"admin","password":{"$regex":"^a"}}
  5. 5

    Escalate to RCE with $where

    If the app uses $where with your input, inject JavaScript that runs in the engine; use it for blind boolean or sleep.

    {"$where":"sleep(5000) || true"}

Learn the theory

Academy: SQL & NoSQL Injection

Frequently asked questions

What is a NoSQL Injection?

It's the equivalent of SQLi but against NoSQL databases like MongoDB: instead of manipulating SQL syntax, you abuse native operators ($ne, $gt, $regex, $where) that the backend interprets when it doesn't sanitize the input.

How is a NoSQL Injection exploited?

You send an object with operators instead of a plain value. For example {"password":{"$ne":null}} makes the password match always succeed, achieving a login bypass; with $regex you blind-exfiltrate data and with $where you run server-side JavaScript.

How do you find NoSQL Injection in bug bounty?

Target APIs on the MERN/MEAN stack. On every login or filter, swap a value for {"$ne":null} or try the query-string variant user[$ne]=x. Changes in the response (login passing, more results) give away the injection.

How do you prevent NoSQL Injection?

Validate that fields are the expected type (string, not object), reject keys starting with $, use libraries like mongo-sanitize or express-mongo-sanitize, and never pass req.body straight into the query.

Difference between NoSQL Injection and SQLi?

Both stem from unsanitized input in the query, but NoSQLi abuses Mongo/Couch-specific JSON operators instead of SQL syntax, and is usually exploited by sending objects instead of strings.

hunters training
650

hunters training

labs from real reports
50

labs from real reports

completions
380

completions

in bounties practiced
$200,000

in bounties practiced

40 flags captured this week·Real reports from HackerOne · Bugcrowd · Intigriti·No commitment·Free Academy
BBLabs · bug bounty training

Practice NoSQL Injection in real labs

Every NoSQL Injection lab replicates a real bug bounty report that got paid. Create your free account, start with the Academy and move to the labs whenever you want.

No card · free Academy · cancel anytime