Skip to content

escape quote and crlf in multipart content-disposition values - #2203

Merged
hyperxpro merged 1 commit into
AsyncHttpClient:mainfrom
jmestwa-coder:multipart-disposition-escape
Jun 19, 2026
Merged

escape quote and crlf in multipart content-disposition values#2203
hyperxpro merged 1 commit into
AsyncHttpClient:mainfrom
jmestwa-coder:multipart-disposition-escape

Conversation

@jmestwa-coder

Copy link
Copy Markdown

Unescaped values in the multipart Content-Disposition header:

  • visitDispositionHeader writes the part name between quotes with no escaping
  • the filename in FileLikeMultipartPart repeats the same pattern
  • a name or filename holding a quote or CR/LF closes the value and injects extra part headers or parts

Percent-escape ", CR and LF in both before the bytes are written, per RFC 7578 section 5.1.

@hyperxpro
hyperxpro merged commit ae2123a into AsyncHttpClient:mainJun 19, 2026
13 checks passed
hyperxpro added a commit that referenced this pull request Jul 18, 2026
Motivation
`MultipartPart` writes several part-header fields (`dispositionType`,
`contentType`, `contentTransferEncoding`, `contentId`, and custom header
names/values) directly into the multipart header without validating
CR/LF characters. This allows header injection or multipart body
splitting. While `name` and `filename` were hardened in #2203, these
fields remained unprotected.
Modification
Add `asciiHeaderBytes(String)` to reject CR/LF characters before
encoding to US-ASCII, and use it for all raw part-header fields. `name`
and `filename` continue using their existing quoted-string escaping.
Result
Raw part-header fields now fail fast on CR/LF input, preventing header
injection while leaving valid values unaffected.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@jmestwa-coder@hyperxpro