Medium severityJavaScript / TypeScriptInjectionMEDIUM confidence
NoSQL Where Operator
MongoDB $where accepts server-side JavaScript and is evaluated with query privileges; a dynamic value here enables NoSQL/code injection.
Standards mapping
Vulnerable vs. safe
Flagged by this check
collection.find({ $where: "this.age > " + req.query.age });Passes - the safe pattern
collection.find({ $where: function () { return true; } });Why it matters & how to fix it
MongoDB $where accepts server-side JavaScript and is evaluated with query privileges; a dynamic value here enables NoSQL/code injection. Rewrite the filter using standard query operators and disable server-side JS.
References
Rule ID integsec-js-nosql-where-operator - engine: Opengrep - license: MIT - Copyright (c) IntegSec Inc.
TurboPentest runs this check automatically
Connect a GitHub repo and this check runs on every white-box pentest - AI-validated and reported with proof, from $99 per target.
Start a pentestRelated checks
- JavaScript / TypeScript - InjectionCode Injection Tainted Input
- JavaScript / TypeScript - InjectionEval Dynamic Argument
- JavaScript / TypeScript - InjectionNoSQL Query From Request
- JavaScript / TypeScript - InjectionOS Command Injection Tainted Input
- JavaScript / TypeScript - InjectionSQL Injection String Concatenation
- JavaScript / TypeScript - InjectionSQL Injection Tainted Input