fix(github): add the Content-Length DoS pre-check to handleOrbRelay - #8940
Conversation
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
handleGitHubWebhook rejects an oversized request via a content-length header check (413 fast-path) before touching the body (JSONbored#197). handleOrbRelay, processing the identical GitHub payload shape, went straight to readBodyWithLimit — enforcing the cap only after buffering up to it. Add the same content-length pre-check so an oversized relay request is rejected at the header stage, matching handleGitHubWebhook's DoS-hardening pattern exactly. Closes JSONbored#8888 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8940 +/- ##
==========================================
+ Coverage 90.56% 90.59% +0.03%
==========================================
Files 96 97 +1
Lines 22490 22584 +94
Branches 3884 3914 +30
==========================================
+ Hits 20367 20461 +94
Misses 1945 1945
Partials 178 178
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Tip ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-26 14:14:31 UTC
Review summary Nits — 5 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
Summary
handleGitHubWebhookrejects an oversized request via acontent-lengthheader check (413fast-path) before touching the body (#197, "Harden GitHub webhook endpoint against large-body DoS").
handleOrbRelay— which processes the identical GitHub payload shape — went straight toreadBodyWithLimit, enforcing the byte cap only after buffering up to it. The two receivers divergedon this bound with no explanation.
Adds the same
content-lengthpre-check (413 before touching the body) tohandleOrbRelay, matchinghandleGitHubWebhook's existing pattern exactly.Test plan
content-lengthheader returns 413 with a bad signature — proving the pre-check short-circuits before the body is read/verified (would be 401 otherwise)content-lengthheader still reaches 202 (the pre-check doesn't false-positive)npx vitest run test/unit/webhook.test.ts— 23/23 pass;tsc --noEmitcleanCloses #8888