Skip to content

escape crlf and quotes in multipart Content-Disposition headers#3417

Merged
velo merged 1 commit into
OpenFeign:masterfrom
alhudz:multipart-content-disposition-escape
Jun 17, 2026
Merged

escape crlf and quotes in multipart Content-Disposition headers#3417
velo merged 1 commit into
OpenFeign:masterfrom
alhudz:multipart-content-disposition-escape

Conversation

@alhudz

@alhudz alhudz commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Repro: send a multipart request whose FormData.fileName (or a File name / field name) contains " or a CRLF, e.g. evil"\r\nX-Injected: 1.
Cause: AbstractWriter.writeFileMetadata and SingleParameterWriter append 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.
Fix: percent-encode \r, \n and " in those parameters inside the writer, matching the WHATWG multipart/form-data encoding rules. Added AbstractWriterTest covering an injected file name and field name.

@yvasyliev

Copy link
Copy Markdown
Contributor

This needs to be backported to #3414

@alhudz

alhudz commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

Backported to 14.x in #3418 - same escaping on AbstractPartEncoder.createHeaders, with a regression test.

@velo velo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This covers the non-streaming multipart writer path well: parameter names and filenames are escaped before they reach Content-Disposition, with regression tests for the injection cases. Checks are green and the change is compatible.

@velo velo merged commit 8694ed6 into OpenFeign:master Jun 17, 2026
3 checks passed
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.

3 participants