# Improper Output Neutralization for Logs (CWE-117) The product does not neutralize or incorrectly neutralizes output that is written to logs. **Stack:** Python - Prevalence: मध्यम 3 भाषाएँ कवर की गईं - Impact: मध्यम समीक्षा अनुशंसित - Prevention: प्रलेखित 4 फिक्स उदाहरण **OWASP:** Injection (A03:2021-Injection) - #3 ## Description Log injection attacks occur when user input is written to log files without proper sanitization. This can allow attackers to forge log entries, inject malicious content, or exploit log analysis tools. ## Prevention 1 Shoulder डिटेक्शन नियमों पर आधारित Log Injection के लिए रोकथाम रणनीतियाँ। ### Python Use structured logging with separate fields for user data instead of string interpolation ## Warning Signs - [MEDIUM] user input flowing directly into log messages without sanitization ## Consequences - एप्लिकेशन डेटा संशोधित करना - गतिविधियाँ छिपाना - अनधिकृत कोड निष्पादित करना ## Mitigations - लॉग में लिखने से पहले सभी इनपुट को सत्यापित और सैनिटाइज़ करें - ऐसे संरचित लॉगिंग प्रारूपों का उपयोग करें जो डेटा को लॉग सिंटैक्स से अलग रखें - उपयोगकर्ता-नियंत्रित डेटा को लॉग में लिखते समय विशेष वर्णों को एनकोड करें ## Detection - Total rules: 4 - Languages: go, javascript, typescript, python ## Rules by Language ### Python (1 rules) - **Log Injection / Log Forging** [MEDIUM]: Detects user input flowing directly into log messages without sanitization. - Remediation: Use structured logging with separate fields for user data. ```python logging.info("Login attempt", extra={'username': username}) ``` Learn more: https://shoulder.dev/learn/python/cwe-117/log-injection