Repository navigation
Description
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:1086definesTRAILER_FORBIDDEN_FIELDS(25 names).HttpContext::filter_request_trailers(editor.rs:2163) elides a field in either list and counts it (editor.rs:2209http.trailer.spoof_vector_elided,editor.rs:2213http.trailer.forbidden_field_elided).lib/src/protocol/mux/pkawa.rs:1528: inhandle_trailer, the decode closure checks onlyTRAILER_SPOOF_VECTOR_HEADERS. Every other field that passesclassify_invalid_h2_header(pkawa.rs:1505) is written into the kawa as aBlock::Header(pkawa.rs:1561).classify_invalid_h2_headerrefuses only the connection-specific fields of RFC 9113 §8.2.2 (connection,keep-alive,proxy-connection,transfer-encoding,upgrade, and ateother thantrailers). No check coverscontent-length,host,authorization,proxy-authorization,cookie,cache-control,expect,max-forwards,pragma,range,if-*,content-encoding,content-type,content-rangeortrailer.handle_trailerruns frompkawa::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) andH2BlockConverter(H2→H2).H2BlockConverterremoveshostandtraileron its own (lib/src/protocol/mux/converter.rsteststest_converter_filters_host_header,test_converter_filters_trailer_header), but it forwardscontent-length,authorization,cookieand the rest.lib/src/metrics/names.rs:266hash2.trailer.spoof_vector_elided. There is no H2 counterpart tohttp.trailer.forbidden_field_elided(names.rs:352).lib/src/protocol/kawa_h1/LIFECYCLE.md:583already states: "The H2 frontend does not yet applyTRAILER_FORBIDDEN_FIELDS:pkawa::handle_trailerrejects the connection-specific fields (RFC 9113 §8.2.2) but forwards, for instance, aContent-LengthorHosttrailer."
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
fix(mux-h2): drop forbidden fields from H2 request trailers and count…
fix(mux-h2): drop forbidden fields from H2 request trailers and count…