# 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:** Go - 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 预防策略。 ### Go Validate email addresses and reject input containing CRLF characters ## Consequences - 修改应用程序数据 - 执行未授权代码 - 隐藏活动 ## Mitigations - 对所有用于头部或日志的输入,剥离或编码 CRLF 序列 - 使用能自动处理头部编码的框架 - 验证输入中不包含意外的控制字符 ## Detection - Total rules: 3 - Languages: go, javascript, typescript, python ## Rules by Language ### Go (1 rules) - **Email Header Injection** [HIGH]: User input flows into email headers without CRLF validation. - Remediation: Reject input containing CRLF characters and validate email addresses. ```go func sanitizeHeader(s string) (string, error) { if strings.ContainsAny(s, "\r\n") { return "", errors.New("invalid characters") } return s, nil } subject, err := sanitizeHeader(r.FormValue("subject")) if err != nil { http.Error(w, "Invalid input", 400) return } ``` Learn more: https://shoulder.dev/learn/go/cwe-93/email-header-injection