Skip to content

generate multipart boundary from SecureRandom#3429

Merged
velo merged 1 commit into
OpenFeign:masterfrom
alhudz:multipart-random-boundary
Jun 20, 2026
Merged

generate multipart boundary from SecureRandom#3429
velo merged 1 commit into
OpenFeign:masterfrom
alhudz:multipart-random-boundary

Conversation

@alhudz

@alhudz alhudz commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Repro: MultipartBoundaryTest drives MultipartFormContentProcessor.process and reads the boundary back out of the generated Content-Type header; on the current code it equals Long.toHexString(System.currentTimeMillis()) for the millisecond the request was built.
Cause: the boundary is derived from the wall clock, so it is low-entropy and guessable. RFC 2046 needs the boundary to never appear in a part, and against attacker-controlled body bytes the only guarantee is that the delimiter is unpredictable. A caller forwarding untrusted data into a field or filename value can embed \r\n--<boundary> and inject or truncate parts, which the Content-Disposition escaping in #3417 cannot cover because part bodies are written verbatim.
Fix: build the boundary from a shared SecureRandom as 128-bit lowercase hex.

@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.

Good security hardening for multipart boundaries. The switch in form/src/main/java/feign/form/MultipartFormContentProcessor.java keeps the existing wire format simple while removing the predictable clock-derived boundary, and MultipartBoundaryTest covers the regression. CI is green and I do not see a compatibility issue here.

@velo velo merged commit 0a250fd into OpenFeign:master Jun 20, 2026
3 checks passed
@velo velo mentioned this pull request Jun 23, 2026
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