# 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