You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by "pjfanning (via GitHub)" <gi...@apache.org> on 2026/10/04 13:16:29 UTC
[PR] http/2: reject a header field carrying CR, LF or NUL (#1297) (1.4.x) [pekko-http]
pjfanning opened a new pull request, #1330:
URL: https://github.com/apache/pekko-http/pull/1330
Adapted backport of #1297 (40b07a21d). It does not cherry-pick: on main the fix sits on top of #961 (malformed HTTP/2 request headers answered with a 400 instead of GOAWAY) and #1251 (HPACK listener collects parse failures), neither of which is on 1.4.x. #961 is a behaviour change with MiMa filters, so rather than porting it this PR keeps 1.4.x's existing handling of malformed headers.
Motivation:
A regular HTTP/2 header field whose value contains CR LF was silently accepted with the value truncated: `RequestParsing.parseHeaderPair` reuses the HTTP/1.1 line parser by building `name + ": " + value + "\r\nx"`, so the parser stops at the first CRLF it meets, which is now the peer's. RFC 9113 8.2.1 says a field name or value carrying NUL, CR or LF makes the message malformed. This is the inbound counterpart of #1258, already on 1.4.x.
Modification:
- `HeaderDecompression`: check each field name and value with `HeaderCompression.hasIllegalChar` before it is dispatched, throw `Http2ProtocolException`, and `failStage` with it, so the connection is closed with GOAWAY(PROTOCOL_ERROR) without an ERROR-level "Error in stage" log.
- Not backported from #1297: the 400-per-stream response, the `ParsingException` rethrow in `RequestParsing.parseHeaderPair` and the `private[http]` widening in `parsing/package.scala` - all only needed for the #961 path.
Result:
A request whose header field name or value contains CR, LF or NUL is no longer accepted with a truncated value; the connection is closed with GOAWAY(PROTOCOL_ERROR) and the request never reaches the handler. On main the same input gets a 400 on that stream and the connection stays open.
Tests:
- New tests: `RequestParsingSpec` "reject a malformed header field" (CR LF, bare LF, NUL in value; CR LF in name) and `Http2ServerSpec` "GOAWAY when a header field carries CR, LF or NUL" (CR LF, NUL), adapted from #1297 to expect a protocol error.
- sbt "http2-tests/testOnly ...RequestParsingSpec ...Http2ServerSpec" - pass (147 tests). With the `HeaderDecompression` change reverted, the six new tests fail.
- sbt http2-tests/test - pass (348 tests).
- sbt http-core/scalafmtCheck http2-tests/Test/scalafmtCheck - pass.
- MiMa not run locally: the change is inside the internal `private[http2]` `HeaderDecompression`; left to the `Check / Binary Compatibility` job.
References:
Backport (adapted) of #1297
--
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: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] http/2: reject a header field carrying CR, LF or NUL (#1297) (1.4.x) [pekko-http]
Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning merged PR #1330:
URL: https://github.com/apache/pekko-http/pull/1330
--
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: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org