# 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:** Python - Prevalence: Hoch Häufig ausgenutzt - Impact: Hoch 3 Regeln mit hohem Schweregrad - Prevention: Dokumentiert 3 Fix-Beispiele **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 Präventionsstrategien für NoSQL Injection basierend auf 1 Shoulder-Erkennungsregeln. ### Python Validate input types and use ObjectId for ID fields ## Warning Signs - [HIGH] untrusted user input being used in NoSQL queries without proper validation ## Consequences - Anwendungsdaten lesen - Anwendungsdaten ändern - Schutzmechanismus umgehen ## Mitigations - Parametrisierte Abfragen für alle Datenspeicher verwenden - Eingaben vor der Verwendung in Abfragen validieren und bereinigen - Das Prinzip der geringsten Rechte auf Datenbankkonten anwenden ## Detection - Total rules: 3 - Languages: go, javascript, typescript, python ## Rules by Language ### Python (1 rules) - **NoSQL Injection** [HIGH]: Detects untrusted user input being used in NoSQL queries without proper validation. - Remediation: Validate and type-check user input before using in queries. ```python from bson import ObjectId object_id = ObjectId(user_id) # Validates format ``` Learn more: https://shoulder.dev/learn/python/cwe-943/nosql-injection