# 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: Średnia Pokryto 3 języków - Impact: Wysoki 3 reguł o wysokim poziomie - Prevention: Udokumentowane 3 przykładów poprawek **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 Strategie zapobiegania dla CRLF Injection oparte na 1 regułach detekcji Shoulder. ### Go Validate email addresses and reject input containing CRLF characters ## Consequences - Modyfikacja danych aplikacji - Wykonanie nieautoryzowanego kodu - Ukrywanie aktywności ## Mitigations - Usuwaj lub koduj sekwencje CRLF z każdego wejścia używanego w nagłówkach lub logach - Korzystaj z frameworków, które automatycznie obsługują kodowanie nagłówków - Sprawdzaj, czy dane wejściowe nie zawierają nieoczekiwanych znaków kontrolnych ## 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