# Improper Neutralization of Special Elements in Data Query Logic (CWE-943) The product generates a query intended to access or manipulate data in a data store, but it does not neutralize or incorrectly neutralizes special elements that can modify the intended logic of the query. **Stack:** JavaScript - Prevalence: 高 頻繁に悪用される - Impact: ハイ 3 件の重大度ハイのルール - Prevention: 文書化済み 3 件の修正例 **OWASP:** Injection (A03:2021-Injection) - #3 ## Description This covers injection attacks against NoSQL databases, ORM frameworks, and other data query mechanisms that differ from traditional SQL injection. ## Prevention 1 件の Shoulder 検出ルールに基づく NoSQL Injection の予防策。 ### JavaScript Validate input types and sanitize MongoDB operators ## Warning Signs - [HIGH] user input flowing into NoSQL database queries without validation ## Consequences - アプリケーションデータの読み取り - アプリケーションデータの変更 - 保護メカニズムの回避 ## Mitigations - すべてのデータストアでパラメータ化クエリを使用する - クエリで使用する前に入力を検証してサニタイズする - データベースアカウントに最小権限の原則を適用する ## Detection - Total rules: 3 - Languages: go, javascript, typescript, python ## Rules by Language ### Javascript (1 rules) - **NoSQL Injection via MongoDB Queries** [HIGH]: Detects user input flowing into NoSQL database queries without validation. - Remediation: Validate input types and use mongo-sanitize to remove operators from user input. ```javascript const sanitized = mongoSanitize(req.body.query); const user = await User.findOne(sanitized); ``` Learn more: https://shoulder.dev/learn/javascript/cwe-943/nosql-injection ### Typescript (1 rules) - **NoSQL Injection via MongoDB Queries** [HIGH]: Detects user input flowing into NoSQL database queries without validation. - Remediation: Validate input types and use mongo-sanitize to remove operators from user input. ```javascript const sanitized = mongoSanitize(req.body.query); const user = await User.findOne(sanitized); ``` Learn more: https://shoulder.dev/learn/javascript/cwe-943/nosql-injection