# Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') (CWE-74) The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. **Stack:** Python - Prevalence: उच्च बार-बार शोषित - Impact: उच्च 3 उच्च गंभीरता वाले नियम - Prevention: प्रलेखित 3 फिक्स उदाहरण **OWASP:** Injection (A03:2021-Injection) - #3 ## Description Software has certain assumptions about what constitutes data and control. Injection problems occur when these assumptions are violated. Attackers exploit this by inserting special characters or instructions that modify the intended interpretation. ## Prevention 1 Shoulder डिटेक्शन नियमों पर आधारित Injection के लिए रोकथाम रणनीतियाँ। ### Python Use system prompts, input sanitization, and length limits for user input to AI models ## Warning Signs - [HIGH] untrusted user input flowing directly into AI/LLM prompts without sanitization ## Consequences - अनधिकृत कोड निष्पादित करना - एप्लिकेशन डेटा पढ़ना - एप्लिकेशन डेटा संशोधित करना - सुरक्षा तंत्र को बायपास करना ## Mitigations - पैरामीटराइज़्ड इंटरफ़ेस का उपयोग करें जो कोड को डेटा से अलग करते हैं - डाउनस्ट्रीम कॉम्पोनेंट्स में उपयोग से पहले सभी इनपुट को सत्यापित और एनकोड करें - जहां संभव हो, इनपुट सत्यापन के लिए allowlist का उपयोग करें ## Detection - Total rules: 3 - Languages: go, javascript, typescript, python ## Rules by Language ### Python (1 rules) - **AI Prompt Injection** [HIGH]: Detects untrusted user input flowing directly into AI/LLM prompts without sanitization. - Remediation: Use system prompts and sanitize user input before including in prompts. ```python messages=[ {'role': 'system', 'content': 'You are a helpful assistant.'}, {'role': 'user', 'content': sanitized_input} ] ``` Learn more: https://shoulder.dev/learn/python/cwe-74/prompt-injection