Skip to content

escape crlf and quotes in streaming multipart part headers#3418

Open
alhudz wants to merge 1 commit into
OpenFeign:14.xfrom
alhudz:multipart-part-encoder-escape
Open

escape crlf and quotes in streaming multipart part headers#3418
alhudz wants to merge 1 commit into
OpenFeign:14.xfrom
alhudz:multipart-part-encoder-escape

Conversation

@alhudz

@alhudz alhudz commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Backport of #3417 to the streaming MultipartFormEncoder added in #3414, as requested there.

Repro: send a streamed multipart request whose part name or FormData filename contains " or a CRLF, e.g. evil"\r\nX-Injected: 1.
Cause: AbstractPartEncoder.createHeaders appends the field name and file name straight into the quoted Content-Disposition parameters, so the value can close the quote and start a new header line or part. Same issue as the legacy writers fixed in #3417, on the new streaming path.
Fix: percent-encode \r, \n and " in those parameters (escapeHeaderParameter), matching the WHATWG multipart/form-data encoding rules. Added AbstractPartEncoderTest covering an injected name and file name.

Sign up for free to 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