NoSQL injection → auth bypass → admin
Login endpoint passes user-supplied JSON into a MongoDB query. Send {"$ne": null} to bypass the password check.
§ Context
Assumed environment: Node + Mongo (or PHP + Mongo) login route accepts JSON body and embeds it in find/findOne unsanitised. No bcrypt-then-compare-string pattern.
§ Steps
- 01Exfil sensitive collectionsExfiltrationT1041— Exfiltration Over C2 Channel
- 02Authenticate as adminInitial AccessT1078— Valid Accounts
- 03Find JSON login endpointReconnaissanceW-RECON-API-DISCO— API Endpoint Discovery
- 04Enumerate users via $regex blindCollectionW-NOSQLI— NoSQL Injection (MongoDB)
- 05Inject $ne / $gt operatorCollectionW-NOSQLI— NoSQL Injection (MongoDB)
{"username":"admin","password":{"$ne":null}}
§ References
§ Frequently asked
- What is the "NoSQL injection → auth bypass → admin" attack path?
- Login endpoint passes user-supplied JSON into a MongoDB query. Send {"$ne": null} to bypass the password check. It chains 5 steps drawn from real-world offensive-security techniques.
- What starting position does this attack require?
- The first step is Exfil sensitive collections (T1041) — a exfiltration primitive. Assumed environment: Node + Mongo (or PHP + Mongo) login route accepts JSON body and embeds it in find/findOne unsanitised.
- What is the final impact of this kill-chain?
- The final step lands on Inject $ne / $gt operator (W-NOSQLI), which falls under Collection. From here, an operator typically pivots into post-exploitation or maintains persistence.
- How can defenders detect or prevent this attack?
- Detection and prevention vary per step. Refer to each linked MITRE ATT&CK entry under "References" — every technique on that page lists defensive controls, detection telemetry, and known threat-actor usage.
§ Related dossiers
- Shared techniques2
Vesting beneficiary replace → silently drain stream
Bug in a custom vesting contract allows anyone to call setBeneficiary on existing schedules. Replace beneficiary with attacker address; legitimate token stream now flows to attacker until released funds are noticed.
- Shared techniques2
Apple Pay Express Transit relay → high-value contactless fraud
Specific configuration (Express Transit + Visa) allowed contactless transactions over £1k without unlock or per-tx auth. Two devices relayed the wallet from victim's pocket to a real terminal.
- Shared techniques2
Mass SMS phish → Okta-style portal → SaaS sprawl (0ktapus)
Wide SMS phishing campaign targeting employees of ~130 organisations with a single phishlet that captures Okta credentials + push approval. Mass automated logins to Twilio, MailChimp, DoorDash et al.
- Shared techniques2
ERC-4626 first-depositor inflation → drain new deposits
Be the first depositor with 1 wei → mint 1 share. Send tokens directly to the vault to inflate share price. Every subsequent depositor's amount, integer-divided by the inflated rate, rounds to zero shares.
- Shared techniques2
Insider admin panel coercion → mass account takeover (Twitter 2020)
Identify employees with access to an internal admin panel. SE / coerce one to use the panel to change target accounts' email + 2FA, then take them over.
- Shared techniques2
SAML signature wrapping (XSW) → impersonate admin
Capture a legitimate SAML response. Re-arrange the XML so the IdP's signature still validates against the original assertion, but the SP parses an attacker-injected assertion claiming Admin.