Skip to content

h2: request trailers still forward the fields TRAILER_FORBIDDEN_FIELDS drops on H1 (Content-Length, Host, Authorization, Cookie, ...) #1714

Closed

Description

@FlorentinDUBOIS

Summary

An HTTP/2 request trailer block still reaches the backend with the fields RFC 9110 §6.5.1 keeps out of trailers: Content-Length, Host, Authorization, Cookie, Cache-Control, the conditionals, Content-Type and the rest of TRAILER_FORBIDDEN_FIELDS. #1695 and #1707 filter the H1 chunked trailer section against both shared lists. The H2 frontend applies only the first list.

Observed on origin/main at a8102115.

Evidence

  • lib/src/protocol/kawa_h1/editor.rs:1086 defines TRAILER_FORBIDDEN_FIELDS (25 names). HttpContext::filter_request_trailers (editor.rs:2163) elides a field in either list and counts it (editor.rs:2209 http.trailer.spoof_vector_elided, editor.rs:2213 http.trailer.forbidden_field_elided).
  • lib/src/protocol/mux/pkawa.rs:1528: in handle_trailer, the decode closure checks only TRAILER_SPOOF_VECTOR_HEADERS. Every other field that passes classify_invalid_h2_header (pkawa.rs:1505) is written into the kawa as a Block::Header (pkawa.rs:1561). classify_invalid_h2_header refuses only the connection-specific fields of RFC 9113 §8.2.2 (connection, keep-alive, proxy-connection, transfer-encoding, upgrade, and a te other than trailers). No check covers content-length, host, authorization, proxy-authorization, cookie, cache-control, expect, max-forwards, pragma, range, if-*, content-encoding, content-type, content-range or trailer.
  • handle_trailer runs from pkawa::handle_header (pkawa.rs:856) when the frontend decodes the HEADERS frame, before the backend protocol is chosen. The same kawa then feeds the H1 serializer (H2→H1, chunked trailer section) and H2BlockConverter (H2→H2). H2BlockConverter removes host and trailer on its own (lib/src/protocol/mux/converter.rs tests test_converter_filters_host_header, test_converter_filters_trailer_header), but it forwards content-length, authorization, cookie and the rest.
  • lib/src/metrics/names.rs:266 has h2.trailer.spoof_vector_elided. There is no H2 counterpart to http.trailer.forbidden_field_elided (names.rs:352).
  • lib/src/protocol/kawa_h1/LIFECYCLE.md:583 already states: "The H2 frontend does not yet apply TRAILER_FORBIDDEN_FIELDS: pkawa::handle_trailer rejects the connection-specific fields (RFC 9113 §8.2.2) but forwards, for instance, a Content-Length or Host trailer."

Reproduction

Over h2, send a POST with no content-length header. A declared length would make the H1 side drop the trailers (see h2.trailers_dropped_content_length). Then send DATA without END_STREAM, then a trailer HEADERS frame with END_STREAM holding authorization: Bearer forged, cookie: session=forged, content-length: 999 and x-checksum: abc123. The H1 backend receives all four fields after 0\r\n. An H2 backend receives all four in the trailer HEADERS frame.

Impact

A backend that merges trailers into its header view, as gRPC-style stacks or headers.extend(trailers) do, sees credentials, cookies, framing and conditionals that never went through the header-block handling. RFC 7230 §4.1.2 names this risk: "processing them as if they were present in the header section might bypass external security filters". An H1 client cannot do this since #1707, so the H2 frontend is now the only way in.

Expected

pkawa::handle_trailer elides every request trailer field named in TRAILER_FORBIDDEN_FIELDS and forwards the rest of the request, as the H1 path does. Each elided field increments a new h2.trailer.forbidden_field_elided, the H2 counterpart of http.trailer.forbidden_field_elided, the same way h2.trailer.spoof_vector_elided mirrors http.trailer.spoof_vector_elided. Connection-specific fields keep their RFC 9113 §8.2.2 stream error. Elided fields keep counting against the trailer field bound.

Activity

  1. added a commit that references this issue on Sep 30, 2026
    dcca0e5
  2. added a commit that references this issue on Oct 2, 2026
    ccf0384
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions