Skip to content

http2: malformed PRIORITY, PUSH_PROMISE, RST_STREAM, SETTINGS and PING frames are refused with the error RFC 9113 names, and a GOAWAY carries the last stream (#641) - #647

Open
MDA2AV wants to merge 2 commits into
mainfrom
fix-641

Conversation

@MDA2AV

@MDA2AV MDA2AV commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Fixes #641.

PRIORITY and PUSH_PROMISE were ignored, an RST_STREAM's payload was never looked at, a SETTINGS ACK
returned before its length check, SETTINGS on a stream and SETTINGS_ENABLE_PUSH past 1 passed, and a
PING was checked only for its length. Each is now refused as RFC 9113 says:

  • PRIORITY (6.3): on stream 0, GOAWAY(PROTOCOL_ERROR). Not five octets, a stream error of
    FRAME_SIZE_ERROR. A stream that depends on itself, a stream error of PROTOCOL_ERROR: RFC 9113 dropped
    that rule with the priority scheme, but RFC 7540 5.3.1 had it, and h2spec and nghttp2 still hold a
    server to it. A PRIORITY may name an idle stream, which no RST_STREAM may (6.4), so for one the
    connection answers with GOAWAY of the same code. A stream that is open is reset as RefuseBody resets
    one: its body reader ends and its response window goes, so nothing more goes out on it. RefuseBody
    now shares that helper, ResetOpenStream.
  • HEADERS: the priority fields are read, and a self-dependency is refused the same way. The block is
    still decoded aside, so HPACK stays in step; a new stream is reset once its block is in, with
    PROTOCOL_ERROR rather than the REFUSED_STREAM of a stream past the concurrency limit, which
    DiscardHeaderBlock now takes from a field.
  • PUSH_PROMISE from a client: GOAWAY(PROTOCOL_ERROR) (8.4).
  • RST_STREAM: on stream 0, GOAWAY(PROTOCOL_ERROR); not four octets, GOAWAY(FRAME_SIZE_ERROR) (6.4).
  • SETTINGS: on a stream, GOAWAY(PROTOCOL_ERROR); an ACK with a payload, GOAWAY(FRAME_SIZE_ERROR) (6.5);
    SETTINGS_ENABLE_PUSH other than 0 or 1, GOAWAY(PROTOCOL_ERROR) (6.5.2).
  • PING on a stream: GOAWAY(PROTOCOL_ERROR) (6.7).
  • GOAWAY's last-stream-id was always 0. It is now the highest stream the client opened, refused ones
    included (6.8): the client learns which requests it may retry, and REFUSED_STREAM already told it
    that a refused one may be.

Unknown frame types are still ignored (4.1).

h2spec 2.6.0 against a reactor serving h2c: the 12 cases of this issue fail on origin/main (5.3.1/1,
5.3.1/2, 5.4.1/1, 6.3/1, 6.3/2, 6.4/1, 6.4/3, 6.5/1, 6.5/2, 6.5.2/1, 6.7/3, 8.2/1) and pass with
this; 35 failures go to 23.

Tests: Http2ControlFrameTests, in Unit. Each malformed frame after a served stream 1 ends the
connection with the expected GOAWAY naming stream 1, and stream 3 behind it is not served; PRIORITY of
four octets or depending on itself resets a request still arriving and the next is served; HEADERS
depending on their own stream are reset with no handler run and HPACK in step. A control sends a
well-formed PRIORITY on a closed and on an idle stream, ENABLE_PUSH 0 and 1, an empty ACK and a PING,
and both streams are served with the PING echoed. Run against origin/main's source every refusal
test fails, "expected [GOAWAY 1 0x1], got []" and the like, and a DATA on an idle stream, refused
before as well, "expected [GOAWAY 1 0x1], got [GOAWAY 0 0x1]"; the control passes either way.

Suites: Unit 321, Chaos 105, Http 113, none failing.

…G frames are refused with the error RFC 9113 names, and a GOAWAY carries the last stream (#641)

PRIORITY and PUSH_PROMISE were ignored, an RST_STREAM's payload was never looked at, a SETTINGS ACK
returned before its length check, SETTINGS on a stream and SETTINGS_ENABLE_PUSH past 1 passed, and a
PING was checked only for its length. Each is now refused as RFC 9113 says:

- PRIORITY (6.3): on stream 0, GOAWAY(PROTOCOL_ERROR). Not five octets, a stream error of
  FRAME_SIZE_ERROR. A stream that depends on itself, a stream error of PROTOCOL_ERROR: RFC 9113 dropped
  that rule with the priority scheme, but RFC 7540 5.3.1 had it, and h2spec and nghttp2 still hold a
  server to it. A PRIORITY may name an idle stream, which no RST_STREAM may (6.4), so for one the
  connection answers with GOAWAY of the same code. A stream that is open is reset as RefuseBody resets
  one: its body reader ends and its response window goes, so nothing more goes out on it. RefuseBody
  now shares that helper, ResetOpenStream.
- HEADERS: the priority fields are read, and a self-dependency is refused the same way. The block is
  still decoded aside, so HPACK stays in step; a new stream is reset once its block is in, with
  PROTOCOL_ERROR rather than the REFUSED_STREAM of a stream past the concurrency limit, which
  DiscardHeaderBlock now takes from a field.
- PUSH_PROMISE from a client: GOAWAY(PROTOCOL_ERROR) (8.4).
- RST_STREAM: on stream 0, GOAWAY(PROTOCOL_ERROR); not four octets, GOAWAY(FRAME_SIZE_ERROR) (6.4).
- SETTINGS: on a stream, GOAWAY(PROTOCOL_ERROR); an ACK with a payload, GOAWAY(FRAME_SIZE_ERROR) (6.5);
  SETTINGS_ENABLE_PUSH other than 0 or 1, GOAWAY(PROTOCOL_ERROR) (6.5.2).
- PING on a stream: GOAWAY(PROTOCOL_ERROR) (6.7).
- GOAWAY's last-stream-id was always 0. It is now the highest stream the client opened, refused ones
  included (6.8): the client learns which requests it may retry, and REFUSED_STREAM already told it
  that a refused one may be.

Unknown frame types are still ignored (4.1).

h2spec 2.6.0 against a reactor serving h2c: the 12 cases of this issue fail on origin/main (5.3.1/1,
5.3.1/2, 5.4.1/1, 6.3/1, 6.3/2, 6.4/1, 6.4/3, 6.5/1, 6.5/2, 6.5.2/1, 6.7/3, 8.2/1) and pass with
this; 35 failures go to 23.

Tests: Http2ControlFrameTests, in Unit. Each malformed frame after a served stream 1 ends the
connection with the expected GOAWAY naming stream 1, and stream 3 behind it is not served; PRIORITY of
four octets or depending on itself resets a request still arriving and the next is served; HEADERS
depending on their own stream are reset with no handler run and HPACK in step. A control sends a
well-formed PRIORITY on a closed and on an idle stream, ENABLE_PUSH 0 and 1, an empty ACK and a PING,
and both streams are served with the PING echoed. Run against origin/main's source every refusal
test fails, "expected [GOAWAY 1 0x1], got []" and the like, and a DATA on an idle stream, refused
before as well, "expected [GOAWAY 1 0x1], got [GOAWAY 0 0x1]"; the control passes either way.

Suites: Unit 321, Chaos 105, Http 113, none failing.
…nection instead of resetting a stream that may never have been opened (#641)

Review of #647. RefusePriority reset any stream at or below the highest the client opened. That
includes an even stream, which only a server opens, and an odd one the client skipped, and RFC 9113
6.4 forbids an RST_STREAM on a stream never opened. Nothing on this branch can tell a skipped stream
from one closed long ago, so only a stream that is still live (still arriving, or still being
answered) is reset now. A PRIORITY on any other stream is answered with GOAWAY of the same code.

Tests, Http2PriorityResetTests in Unit:
- A PRIORITY of four octets on an even stream, and on an odd one skipped below the highest, ends
  the connection. Against the previous commit's source they fail with "expected [GOAWAY 5 0x6], got
  [RST_STREAM 2 0x6]" (and 3).
- Coverage the review asked for, of what the previous commit already did, so these fail against
  origin/main's source and pass against the previous commit's:
  - A PRIORITY of four octets, and trailers whose priority depends on their own stream, on a stream
    whose handler has a body read parked and a flush parked on credit: the read raises, the flush
    wakes and reports the peer gone, only the RST_STREAM goes out on the stream, and a self-dependent
    trailer block still keeps HPACK in step. With ResetOpenStream's ReleaseCreditWaiters removed,
    both fail with "the flush parked on credit never woke".
  - A self-dependent HEADERS whose block continues in CONTINUATION is reset once the block is in,
    and HPACK stays in step.
  - Self-dependent trailers reset a buffered request that is still arriving.
Http2ControlFrameTests.Fields is internal now, so these tests can use it.

Suites: Unit 327, Chaos 105, Http 113, none failing.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

http2: PRIORITY, PUSH_PROMISE, RST_STREAM, SETTINGS and PING frames skip their checks, so malformed control frames are taken

1 participant