Skip to content

fix: Use correct error codes for frame errors#900

Open
ArniDagur wants to merge 1 commit intohyperium:masterfrom
ArniDagur:fix/frame-size-error-codes
Open

fix: Use correct error codes for frame errors#900
ArniDagur wants to merge 1 commit intohyperium:masterfrom
ArniDagur:fix/frame-size-error-codes

Conversation

@ArniDagur
Copy link
Copy Markdown
Contributor

@ArniDagur ArniDagur commented May 3, 2026

Previously all frame errors produced GOAWAY(PROTOCOL_ERROR). RFC 9113 requires specific error codes:

Error Old New Comment
BadFrameSize PROTOCOL_ERROR FRAME_SIZE_ERROR
InvalidPayloadLength PROTOCOL_ERROR FRAME_SIZE_ERROR
InvalidPayloadAckSettings PROTOCOL_ERROR FRAME_SIZE_ERROR
InvalidInitialWindowSize PROTOCOL_ERROR FLOW_CONTROL_ERROR New variant, split from InvalidSettingValue
Hpack(_) PROTOCOL_ERROR COMPRESSION_ERROR
TooMuchPadding PROTOCOL_ERROR PROTOCOL_ERROR
InvalidSettingValue PROTOCOL_ERROR PROTOCOL_ERROR
InvalidWindowUpdateValue PROTOCOL_ERROR PROTOCOL_ERROR
InvalidStreamId PROTOCOL_ERROR PROTOCOL_ERROR
MalformedMessage PROTOCOL_ERROR PROTOCOL_ERROR
InvalidDependencyId PROTOCOL_ERROR PROTOCOL_ERROR

One motivation to fix this beyond RFC compliance is that it's a source of "uninteresting" discrepancies when doing comparative fuzzing between different HTTP2 implementations.

Previously all frame parsing errors in framed_read.rs produced
GOAWAY(PROTOCOL_ERROR). RFC 9113 requires specific error codes:

  Error                      Old              New                 Comment
  ─────────────────────────  ───────────────  ──────────────────  ───────────────────────────────────
  BadFrameSize               PROTOCOL_ERROR   FRAME_SIZE_ERROR
  InvalidPayloadLength       PROTOCOL_ERROR   FRAME_SIZE_ERROR
  InvalidPayloadAckSettings  PROTOCOL_ERROR   FRAME_SIZE_ERROR
  InvalidInitialWindowSize   PROTOCOL_ERROR   FLOW_CONTROL_ERROR  New variant, split from InvalidSettingValue (§6.5.2)
  Hpack(_)                   PROTOCOL_ERROR   COMPRESSION_ERROR
  TooMuchPadding             PROTOCOL_ERROR   PROTOCOL_ERROR
  InvalidSettingValue         PROTOCOL_ERROR   PROTOCOL_ERROR
  InvalidWindowUpdateValue   PROTOCOL_ERROR   PROTOCOL_ERROR
  InvalidStreamId            PROTOCOL_ERROR   PROTOCOL_ERROR
  MalformedMessage           PROTOCOL_ERROR   PROTOCOL_ERROR
  InvalidDependencyId        PROTOCOL_ERROR   PROTOCOL_ERROR
@ArniDagur ArniDagur changed the title fix: use correct error codes for frame parsing errors fix: Use correct error codes for frame errors May 3, 2026
@seanmonstar
Copy link
Copy Markdown
Member

This is probably fine. I just wanted to note some things from RFC 9113 Section 5.4 (and we use for security reasons in h2 sometimes):

Additionally, an endpoint MAY use any applicable error code when it detects an error condition; a generic error code (such as PROTOCOL_ERROR or INTERNAL_ERROR) can always be used in place of more specific error codes.

An endpoint can end a connection at any time. In particular, an endpoint MAY choose to treat a stream error as a connection error.

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.

2 participants