aperture: don't buffer the body of an h2c upgrade request #357
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 191 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.315
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #357"
general
weight: 0.35
hieblmi
On plaintext listeners (
insecure: true, and the Tor listener), the x/net h2c handler reads the whole body of a request that asks to upgrade to h2c into memory before it hands the request on, so it can replay it as the first HTTP/2 stream. That happens before aperture sees the request, so the body is held in full before routing, auth and rate limits apply, bounded only by the read timeout (the Tor listener has none). x/net's own docs say to limit it.Fix
A small handler in front of the h2c handler drops the
Upgradeheader from a request that asks for h2c and has a body (Content-Lengthabove 0, or chunked). The request is then served over HTTP/1 with its body read as usual. A server may ignore an Upgrade header (RFC 9110 section 7.8), and the client gets a normal response. For example,curl --http2 -d ...againsthttp://now gets an HTTP/1.1 response instead of switching to h2c.Not affected:
Tests
TestH2CUpgradeWithBodyIsNotBuffered: for a body with a Content-Length, a chunked body, andContent-Length: 0with a chunked body, the handler gets the upgrade request while most of its 1 MiB body is still held back by the client, and serves it over HTTP/1. Without the fix the handler is only called once the whole body has arrived, and the test fails.TestH2CUpgradeWithoutBodyUpgrades: an upgrade request without a body gets101 Switching Protocolsand is served over HTTP/2.