oscerd opened a new pull request, #27944:
URL: https://github.com/apache/camel/pull/27944

   # CAMEL-25704: camel-undertow - refuse a request target or header value with 
control characters
   
   ## What
   
   The undertow producer writes the path, query and header values of the 
outgoing HTTP request to the socket one
   character at a time (`io.undertow.client.http.HttpRequestConduit` does 
`buffer.put((byte) string.charAt(i))`), with no
   validation. So:
   
   - a carriage return or line feed in the request path/query or in a header 
value broke it into a further line;
   - a character above `0xFF` was narrowed to a single, different byte (for 
example `U+010A` was written as a line feed).
   
   The producer decodes a percent-encoded `CamelHttpPath` / `CamelHttpQuery` 
before building the request target
   (`URISupport.pathAndQueryOf` uses the decoded `URI.getPath()` / 
`URI.getQuery()`), so a percent-encoded control
   character in those headers became a real control character at that point.
   
   ## Change (camel-undertow only)
   
   - New helper `UndertowHelper.checkWriteable(what, value)`: refuses a value 
that holds a control character, `DEL`, or a
     character above `0xFF`. `SP` and `HTAB`, which do not change the request 
framing, are allowed.
   - `UndertowProducer.process` validates the request target (after 
`pathAndQueryOf`) and fails the exchange with an
     `IllegalArgumentException` if it is not writeable, instead of handing it 
to the client. The `toHttpRequest` call is
     wrapped so a rejected header value fails the exchange the same way (rather 
than escaping the async callback).
   - `DefaultUndertowHttpBinding.toHttpRequest` validates every outgoing header 
value with the same helper (Undertow
     validates header *names* but not values).
   
   The decoding of `CamelHttpPath` / `CamelHttpQuery` is deliberately kept: the 
rest producer double-encodes its query
   parameters and relies on the undertow producer decoding once (CAMEL-15410, 
`RestUndertowProducerEncodingTest`).
   Changing the producer to send the raw, still-encoded target would regress 
that round trip, so this change keeps the
   existing decoding and only refuses characters that cannot be written as they 
are.
   
   ## Tests
   
   - `UndertowProducerEncodedUriTest`: a percent-encoded CR/LF in 
`CamelHttpQuery` or `CamelHttpPath`, and a CR/LF in a
     header value, make the exchange fail; an ordinary query is still sent.
   - Existing `RestUndertowProducerEncodingTest` keeps passing (the rest round 
trip is unchanged).
   - Full `camel-undertow` module suite is green (232 run, 0 failures, 1 
skipped).
   
   ## Docs
   
   - Upgrade-guide note in `camel-4x-upgrade-guide-4_24.adoc`.
   
   Relates to CAMEL-25704.
   
   _Claude Code on behalf of oscerd_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to