Skip to content
Vol. 1 · Ed. 2026
CyberGlossary
Entry № 837

NoSQL Injection

Reviewed byCybersecurity entrepreneur & security researcher

What is NoSQL Injection?

NoSQL InjectionAn injection attack that manipulates the operators, JSON, or query DSL of a NoSQL database to bypass logic or extract data.


NoSQL injection exploits applications that build queries for document or key-value stores (such as MongoDB, CouchDB, or Elasticsearch) from untrusted input. Instead of SQL syntax, attackers tamper with the JSON structure of a request, query operators like $ne, $gt, or $regex, or server-side JavaScript in a $where clause. A canonical login bypass submits {"$ne": null} as the password so the comparison matches any stored value; $regex payloads then enumerate secrets one character at a time through blind, boolean- or time-based oracles.

A high-impact real-world case was CVE-2021-22911 in Rocket.Chat 3.11–3.13 (CVSS 9.8). SonarSource researchers showed the unauthenticated getPasswordPolicy endpoint accepted a JSON object in its token parameter, letting an attacker inject a $regex operator to leak a password-reset token character by character, take over an admin account, and chain to remote code execution.

flowchart LR
  A["Attacker sends JSON<br/>with operator payload"] --> B["App builds query<br/>from raw input"]
  B --> C{"Object where a<br/>string was expected?"}
  C -->|"No cast / no validation"| D["DB evaluates operator<br/>$ne / $gt / $regex"]
  D --> E["Auth bypass or<br/>document/secret leak"]
  C -->|"Cast to string<br/>+ schema check"| F["Payload treated as a<br/>literal value: rejected"]

Defences: cast inputs to the expected primitive type, reject objects where a string is expected, validate against a strict schema, use driver query builders with explicit operators, disable server-side JavaScript ($where, mapReduce), and apply least-privilege database roles.

● Examples

  1. 01

    Sending {"username": "admin", "password": {"$ne": null}} to a MongoDB login that compares the password against a string.

  2. 02

    Injecting a $regex operator to leak a secret one character at a time through a blind, boolean-based oracle.

● Frequently asked questions

What is NoSQL Injection?

An injection attack that manipulates the operators, JSON, or query DSL of a NoSQL database to bypass logic or extract data. It belongs to the Attacks & Threats category of cybersecurity.

What does NoSQL Injection mean?

An injection attack that manipulates the operators, JSON, or query DSL of a NoSQL database to bypass logic or extract data.

How do you defend against NoSQL Injection?

Defences for NoSQL Injection typically combine technical controls and operational practices, as detailed in the full definition above.

What are other names for NoSQL Injection?

Common alternative names include: NoSQLi.

● Related terms

● See also