Summary
CGI for Perl can place an attachment filename into a quoted Content-Disposition parameter without escaping double quotes. If an application uses request-controlled data as that filename, the response header may contain an additional filename parameter, potentially changing the name under which a recipient saves the response.
Affected context
The issue affects applications using CGI for Perl versions before 5.00 when they generate attachment headers with header(-attachment => $name). It becomes risky when $name can be influenced by request data and is inserted into the quoted header parameter without appropriate encoding.
Exploit preconditions
- Attack surface: An application endpoint that returns a response with a
Content-Dispositionattachment header - Required access: Ability to supply or influence the attachment name through a request; authentication requirements depend on the application
- Trigger point: Generation of the response header using the supplied attachment name
- Why exploitation is possible: Double quotes in the value are not escaped, allowing the parameter structure to be altered and a second filename parameter to be introduced
Why this happens
The underlying issue is improper output encoding for a structured HTTP header, classified as CWE-116. The attachment name is inserted into a quoted Content-Disposition parameter without escaping characters that have structural meaning in that context. As a result, input intended as data can be interpreted as part of the header's parameter syntax.
Potential impact
- A response may advertise an attacker-influenced filename to the recipient
- A client may save the response under a different name than the application intended
- Misleading filenames could contribute to user confusion or unsafe file handling
General mitigation guidance
Defensive patterns focus on keeping untrusted data separate from header syntax.
- Use header-generation APIs that correctly encode or validate parameter values.
- Apply context-appropriate escaping for quoted header parameters, including special characters such as double quotes.
- Prefer server-controlled attachment names or map user input to a constrained set of permitted names.
- Validate filenames against a clear allowlist and reject values that do not meet the application's requirements.
- Avoid granting unnecessary access to endpoints that generate downloadable responses.
How teams detect issues like this
Review attachment-header construction for direct interpolation of request-controlled values and check whether parameter values are encoded for the relevant header context. Static analysis can flag user input flowing into response headers without validation or encoding. Code review and policy checks can require use of approved header-building APIs and constrained filename handling; automated review tools may help identify these patterns.

