Skip to content

generate multipart boundary from SecureRandom#3429

Open
alhudz wants to merge 1 commit into
OpenFeign:masterfrom
alhudz:multipart-random-boundary
Open

generate multipart boundary from SecureRandom#3429
alhudz wants to merge 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.

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.

1 participant