Skip to content

Harden HTTP/2 CR/LF in trailer header values #68371

Closed

Description

@DeagleGross

Kestrel correctly rejects \r and \n in regular HTTP/2 request header literals, but skips that check in two places:

  1. Request trailers — HttpProtocol.OnTrailer calls GetRequestHeaderString(..., checkForNewlineChars: false), so a trailer value containing CR or LF is stored in RequestTrailers without error.
  2. HPACK dynamic-table retrieval — when a header is referenced by dynamic-table index and has no static-table alias, Http2Connection.OnHeaderCore dispatches with checkForNewlineChars: false.

RFC 7540 §10.3 requires CR/LF inside a header field value to be treated as a stream/connection error.

Activity

  1. added
    area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
    on Aug 12, 2026
  2. amf-fs commented on Aug 14, 2026

    @amf-fs
    Contributor

    Hi @DeagleGross, I did a quick check in both paths, and it looks like we just need to turn on the validation GetRequestHeaderString(..., checkForNewlineChars: true).

    I’m still figuring out the networking internals, so I’d like to confirm the approach before proceeding. Thanks!

  3. DeagleGross commented on Aug 18, 2026

    @DeagleGross
    MemberAuthor

    @amf-fs hey, yep, that's basically all that needs to be done. Dont forget to write the unit-tests to lockdown the behavior and make sure change works correctly. Thanks!

  4. amf-fs commented on Aug 24, 2026

    @amf-fs
    Contributor

    Thanks for the clarification. PR submitted; glad to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions