# Improper Neutralization of CRLF Sequences ('CRLF Injection') (CWE-93) The product uses CRLF (carriage return line feed) as a special element, e.g. to separate headers or records, but it does not neutralize or incorrectly neutralizes CRLF sequences from inputs. **Stack:** Python - Prevalence: 中 覆盖 3 种语言 - Impact: 高 3 条严重级别为高的规则 - Prevention: 已记录 3 个修复示例 **OWASP:** Injection (A03:2021-Injection) - #3 ## Description CRLF injection can be used to inject malicious headers in HTTP responses (HTTP response splitting), forge log entries, or manipulate other protocols that use CRLF as a delimiter. ## Prevention 基于 1 条 Shoulder 检测规则的 CRLF Injection 预防策略。 ### Python Strip newline characters from email headers before use ## Warning Signs - [HIGH] user input used in email headers without newline sanitization ## Consequences - 修改应用程序数据 - 执行未授权代码 - 隐藏活动 ## Mitigations - 对所有用于头部或日志的输入,剥离或编码 CRLF 序列 - 使用能自动处理头部编码的框架 - 验证输入中不包含意外的控制字符 ## Detection - Total rules: 3 - Languages: go, javascript, typescript, python ## Rules by Language ### Python (1 rules) - **Email Header Injection** [HIGH]: Detects user input used in email headers without newline sanitization. - Remediation: Remove newlines from email headers before use. ```python safe_subject = subject.replace('\r', '').replace('\n', '') ``` Learn more: https://shoulder.dev/learn/python/cwe-93/email-injection