# 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