Summary
CGI for Perl has HTTP header injection flaws when certain header values are checked before entity decoding or are not checked for newline characters. If an application passes attacker-controlled request data into these values, an attacker may add response headers or split the HTTP response.
Affected context
The issue affects CGI versions before 5.00 when applications use the affected header-writing paths. In header, the risk applies when autoEscape is off and extra header values are entity-decoded after the newline check. multipart_start does not check header values for newlines, and do_push does not check the type it prints in each part. The vulnerability becomes relevant when request-controlled data reaches these values.
Exploit preconditions
- Attack surface: HTTP responses generated through the affected CGI header or multipart-writing functions
- Required access: The ability to send requests whose data is used by the application in relevant header or part values; authentication depends on the application
- Trigger point: Response generation through
header,multipart_start, ordo_push - Why exploitation is possible: Newline validation may be absent or may occur before entity decoding, allowing CR or LF characters to reach response output
Why this happens
The underlying issue is improper neutralization of CR and LF characters in HTTP headers, mapped to CWE-113: Improper Neutralization of CRLF Sequences in HTTP Headers ('HTTP Request/Response Splitting'). The insecure pattern is validating a value before transformations that can introduce control characters, or emitting values without newline checks. Unchecked output types can also undermine assumptions about what is written into multipart responses.
Potential impact
- An attacker may add unauthorized headers to an HTTP response.
- A crafted response could be split, potentially affecting how clients or intermediaries interpret it.
- Depending on the application and deployment, response handling or downstream security controls could be affected.
General mitigation guidance
Defensive approaches focus on treating values used in response headers and multipart output as untrusted.
- Prefer APIs that safely construct headers and reject CR and LF characters.
- Normalize or decode values before validation, then enforce strict character and type checks at the output boundary.
- Avoid passing request data directly into header values; use allowlisted, application-defined values where practical.
- Apply least privilege and limit the impact of application compromise through appropriate runtime and deployment boundaries.
How teams detect issues like this
- Use static analysis to find request-derived values flowing into header or multipart output functions.
- Review whether validation occurs after all decoding and normalization, and whether every output path rejects newline characters and unexpected types.
- Enforce code-review or CI policies that prohibit untrusted data in response metadata without an approved validation or safe-construction step.
- Use security testing to verify that response generation handles newline-bearing and unexpected-type inputs safely.

