Code
Database query built from raw request input (NoSQL injection)code.nosql-injection
A value from the request goes into a MongoDB/Mongoose query without being forced to a string. JSON lets an attacker send an object instead, like `{"email": {"$ne": null}, "password": {"$ne": null}}`, which matches the first user and logs them in without a password, or reads and deletes records they should never see.
- In force Rule code.nosql-injection
- 3 clauses
At a glance
| Severity | high |
|---|---|
| Certainty | Needs review — a heuristic; confirm before changing code |
| Looks at | your source code |
| When it runs | Runs on every scan |
How to fix it
Validate the body with a schema first (`const { email } = z.object({ email: z.string().email() }).parse(req.body)`), or cast each value (`String(req.body.email)`), and add `express-mongo-sanitize` (or `mongoose.set("sanitizeFilter", true)`).
Check your own app
Run npx scanlyfix scan in your project. Every finding gets an id; after fixing, npx scanlyfix verify <id> proves it is gone.
If it is a false positive in your project, silence that one line with // scanlyfix-ignore-next-line code.nosql-injection -- <why>.
Your code stays
on your machine
Only findings are uploaded, and only to your own dashboard.
ScanlyFix
Security, privacy pages, SEO and AI visibility checked in one scan, with fixes your AI editor can apply.
Home