# Improper Neutralization of CRLF Sequences in HTTP Headers ('HTTP Response Splitting') (CWE-113) The product receives data from an HTTP agent/component, and it places this data in HTTP response headers without neutralizing CRLF sequences. **Stack:** JavaScript - Prevalence: 中 覆盖 3 种语言 - Impact: 高 2 条严重级别为高的规则 - Prevention: 已记录 3 个修复示例 **OWASP:** Injection (A03:2021-Injection) - #3 ## Description An attacker can inject CRLF sequences into HTTP headers to create additional headers or response body content. This can lead to cache poisoning, cross-site scripting, or other attacks. ## Prevention 基于 1 条 Shoulder 检测规则的 HTTP Response Splitting 预防策略。 ### JavaScript Strip CRLF characters from user input before setting HTTP response headers ## Warning Signs - [HIGH] user input flowing into HTTP response headers without CRLF sanitization ## Consequences - 执行未授权代码 - 绕过保护机制 - 修改应用程序数据 ## Mitigations - 切勿将用户输入直接放入 HTTP 响应头 - 对所有可能进入头部的用户输入进行净化 - 使用框架提供的、可处理编码的头部设置方法 ## Detection - Total rules: 3 - Languages: go, javascript, typescript, python ## Rules by Language ### Javascript (1 rules) - **HTTP Header Injection (Response Splitting)** [HIGH]: Detects user input flowing into HTTP response headers without CRLF sanitization. - Remediation: Remove CRLF characters from user input before setting headers. ```javascript const sanitized = userInput.replace(/[\r\n]/g, ''); res.setHeader('X-Custom-Header', sanitized); ``` Learn more: https://shoulder.dev/learn/javascript/cwe-113/header-injection ### Typescript (1 rules) - **HTTP Header Injection (Response Splitting)** [HIGH]: Detects user input flowing into HTTP response headers without CRLF sanitization. - Remediation: Remove CRLF characters from user input before setting headers. ```javascript const sanitized = userInput.replace(/[\r\n]/g, ''); res.setHeader('X-Custom-Header', sanitized); ``` Learn more: https://shoulder.dev/learn/javascript/cwe-113/header-injection