# NoSQL Injection

*noun*

say it: **“noh-SEE-kwul in-JEK-shun”** **/noʊ ˈsikwəl ɪnˈdʒɛkʃən/**

An attack that sneaks database query operators into a request, so a document database runs a search the attacker controls.

## What is **NoSQL injection**?

**NoSQL injection** is an attack where someone sends a query operator, such as `{ "$ne": null }`, where the API expects plain text. If the API puts it straight into a filter, the database runs a search the attacker chose. Check that each value is text before using it.

```javascript
// POST /reset-password with { "email": { "$ne": null } }
const user = await users.findOne({ email: req.body.email });
// finds the first user in the collection, not the one the caller named
```

## In a sentence

- “A **NoSQL injection** slipped { "$ne": null } into the filter and found the first account in the collection.”
- “Checking that email is a string with Zod blocked the **NoSQL injection** in the coffee club's sign-in.”

Level: Freelancer · [More MongoDB terms at this level](https://www.ask-codey.com/glossary?category=mongodb&level=4)

Updated: November 19, 2026

Source: https://www.ask-codey.com/glossary/nosql-injection
