Explore our new Cybersecurity Terms Glossary, explained by our experts.
Cybersecurity Terms Glossary
NoSQL injection manipulates queries sent to document and key-value databases, typically by smuggling query operators into data that the application expected to be a plain string.

What Is NoSQL Injection?
Dropping SQL does not drop injection. NoSQL databases replace a text query language with structured documents, usually JSON, and the application still builds those documents from user input. The payload is not a quotation mark and a comment marker; it is an operator object where the code expected a string. MongoDB is the usual setting, but CouchDB, Elasticsearch, Redis, and Cassandra all have equivalents.
A login handler that runs db.users.findOne({ user: req.body.user, pass: req.body.pass }) looks perfectly safe. It is safe only while those two values are strings. Express parses user[$ne]=&pass[$ne]= in a form body into nested objects, and a JSON request body can contain {"user": "admin", "pass": {"$ne": null}} directly. Either way the query becomes “find the user whose password is not null”, and the first matching account is returned.
The operators that matter most are small in number. $ne and $gt bypass comparisons, $regex allows a password or token to be recovered character by character, $in tries a list of candidates in one request, and $exists probes the shape of the document. None of them requires any syntax error in your code.
The more severe variant involves evaluation. The $where operator, and the mapReduce and group functions, accept JavaScript that the database executes. Input concatenated into one of these is code injection against the database server, not merely a filter bypass, and a payload containing a loop will also hang the connection. MongoDB disables server-side JavaScript by default in recent versions through the security.javascriptEnabled setting, and leaving it disabled removes the whole category.
Blind extraction uses the same ideas as blind SQL injection. A regular expression anchored to the first character, tested against the response or against the time taken, recovers a secret one character at a time, and a tool such as NoSQLMap automates the loop.
Aggregation pipelines deserve their own attention, because a pipeline stage built from user input can add a $lookup that joins a collection the user should never see, or a $out stage that writes results into a new collection. In Elasticsearch, passing a user-supplied string into a query string query exposes field enumeration and wildcard searches across indices. In Redis, unescaped values in commands produce command injection through protocol framing.
$jsonSchema validation enforces document structure as a second layer.$where entirely.Testing is quick once you know the shape. Replace a string parameter with an object containing $ne, then with $regex, and compare the responses; repeat in both form-encoded and JSON bodies, because frameworks parse them differently. Scanners detect comparatively few of these cases, so the checks belong in a manual test plan and in secure code review, where a query built from an unvalidated request body is visible on the page. Our web application security testing covers document database back ends and their aggregation layers alongside relational ones.
Not inherently, but the defaults have historically been weaker and the defences are less familiar. There is no universal equivalent of a prepared statement, so protection depends on type checking and schema validation written by the application developer. Several document databases also shipped with no authentication enabled by default, which led to large numbers of exposed instances.
It helps considerably, because Mongoose casts incoming values to the types declared in the schema and rejects an operator object supplied where a string belongs. The protection ends where developers bypass it: raw query methods, mixed or unspecified schema types, strict mode disabled, and aggregation pipelines built by hand all return you to unvalidated input.
Take an authentication or search parameter and replace its string value with an object such as a not-equal operator set to null, sending it both as a JSON body and as bracketed form parameters. A successful login, a different result count, or a measurable delay indicates the query is being built from raw input. Follow up with a regular expression operator to confirm.
Yes, unless a specific feature depends on it, and most do not. Operators that evaluate JavaScript turn an injection into code execution on the database server and make denial of service trivial through an infinite loop. Recent MongoDB versions disable it by default; confirm the setting in your deployment rather than assuming the version behaves as documented.
You May Be Interested In These
Cybersecurity Terms
17 November 2026
What Is the Difference Between Modbus TCP and Serial?
Read More
We use a few cookies that are needed to make this website work, and they are always on. We would also like to set analytics cookies, to see which pages are useful; functional cookies, so that our live chat works; and advertising cookies, to measure our campaigns. We will not set any of those until you say yes, and you can change your mind at any time from the Cookie Settings link in the footer.
Choose the cookies you are happy for us to use. Strictly necessary cookies are always on; everything else is off until you turn it on.
These cookies keep the website working: they hold your security checks, your form submissions and the choice you make here. The site cannot run without them, so they are always on.
These let our live chat open and remember your conversation, and let the newsletter sign-up work. Switch them off and the chat window will not appear.
These tell us which pages are read and how people find us, so that we can improve the site. The reports are about groups of visitors, never about you personally.
These let us measure our advertising and show you our adverts on other websites, such as LinkedIn, Google and Meta. Switch them off and you will still see adverts, but they will be less relevant.