Skip to content

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

Open
alhudz wants to merge 1 commit into
OpenFeign:masterfrom
alhudz:multipart-content-disposition-escape
Open

escape crlf and quotes in multipart Content-Disposition headers#3417
alhudz wants to merge 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.

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