Skip to content

fix(mitm): keep HTTP/2 framing that ends on HEADERS - #111

Open
AuceptinFang wants to merge 2 commits into
mainfrom
fix/h2-bodiless-end-stream
Open

AuceptinFang wants to merge 2 commits into
mainfrom
fix/h2-bodiless-end-stream

Conversation

@AuceptinFang

@AuceptinFang AuceptinFang commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

The HTTP/2 relay always opened the forwarded stream without END_STREAM and closed it afterwards with an empty DATA frame, in both directions.

  • Requests. A GET that the client ended on its HEADERS frame reached the origin as a request with an empty body. claude.ai answers such a GET /edge-api/bootstrap/{org}/app_start with 500, and Claude Desktop then reports "Service temporarily unreachable" as soon as its claude.ai traffic is decrypted by the broker.
  • Responses. A response that the origin ended on HEADERS reached the client with a trailing empty DATA frame. For a 304 that keeps the representation's Content-Length, that frame makes the response malformed, and h2 clients reset the stream with PROTOCOL_ERROR.

Change

Each side now forwards the peer's own framing. The relay samples whether the client ended the request on HEADERS before the body is consumed and opens the upstream stream with END_STREAM in that case. The one exception is a body that request inspection adds to a bodiless request, which is still sent. The response head is likewise forwarded with END_STREAM when the origin ended the response on HEADERS. The request and response halves are separate commits.

AuceptinFang and others added 2 commits November 25, 2026 11:41
The HTTP/2 relay always opened the upstream request without END_STREAM
and closed it with an empty DATA frame, so a GET the client ended on
HEADERS reached the origin as a request with an (empty) body. claude.ai
answers such requests to /edge-api/bootstrap/{org}/app_start with 500,
which breaks Claude Desktop once its traffic goes through the broker.

Sample whether the client ended the request on HEADERS before the body
is consumed, and forward the head with END_STREAM in that case unless
inspection produced a body to send.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The response half had the same framing bug as requests: the relay sent
the response head without END_STREAM and closed with an empty DATA
frame. For a 304 that carries the representation's Content-Length, the
trailing DATA frame makes the response malformed and h2 clients reset
the stream with PROTOCOL_ERROR.

Forward the response head with END_STREAM when the origin ended the
response on HEADERS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@SKTT1Ryze
SKTT1Ryze force-pushed the fix/h2-bodiless-end-stream branch from f8c8a6b to a5fcbff Compare November 25, 2026 03:41
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.

1 participant