Header injection

From thejefflarson/soundcheck · View interactive version

Header injection is an AI agent skill from the GitHub repository thejefflarson/soundcheck. Detects HTTP response header construction from user input vulnerable to CRLF injection. Use when writing code that sets HTTP response headers using values from user input, request parameters, or external data. Also invoke when constructing email headers, Content-Disposition filenames, or Location he

How to use this skill

Skill file

HTTP Header Injection Security Check (CWE-113)

What this checks

Protects against HTTP response header injection where user input containing CR/LF

characters is included in response headers, allowing attackers to inject arbitrary

headers or split the HTTP response. Exploitation leads to cache poisoning, session

fixation, XSS via injected headers, and response splitting.

Vulnerable patterns

Fix immediately

Flag the vulnerable code and explain the risk. Translate the principles below to the

audited file's language and HTTP framework — use that stack's documented header API

and string-sanitization helpers.

For each finding, establish these properties:

  1. **Every header value derived from user input is stripped of CR/LF before it

reaches the header-set call.** A single newline sequence in a value ends the

header block and starts a new header (or a new response body). The strip

happens at or before the call site — relying on the framework to reject it is

fragile across versions.

  1. Forwarded headers are sanitized too. Values read from incoming requests

(correlation IDs, user agents, custom headers) are attacker-controlled just

like form inputs. Echoing them into outgoing responses or logs without

stripping is the same vulnerability.

  1. Content-Disposition filenames are normalized — CR/LF stripped, quotes

escaped, and for international characters use the RFC 5987 filename* form

rather than raw UTF-8 in the header value.

  1. Redirect Location headers are validated too. A newline sequence in the

target URL splits the response; see the open-redirect skill for target-host

validation.

Verification

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.