Repository navigation
Conversation
…nd swallowed late errors The raw-body middleware buffered the ENTIRE request body into memory with no size limit, and HMAC verification ran only after buffering — on a path the rate limiter deliberately skips. Unauthenticated, unlimited-rate, unbounded per-request memory (CodeQL #10, real coverage defect from the #425 verification tranche). Enforcement (25 * 1024 * 1024 = 26,214,400 bytes, GitHub's documented webhook ceiling exactly): - Streaming path: actual received bytes counted during reading; on crossing the cap → 413 exactly once, connection: close, listeners detached, remainder drained without buffering under a no-op error swallow guard (a resumed stream with no error listener emits an UNCAUGHT error if the socket dies mid-drain — review finding, fixed). Socket destruction was implemented and tested first, then rejected: the RST races the in-flight 413. - Declared-length path: oversized Content-Length rejected 413 before reading with the same disposition — connection: close, listener removal for the pre-listener window, drained under the same swallow guard. The header check is an optimization only; actual bytes are the enforcement. - Oversized requests never reach HMAC verification, JSON parsing, or dispatch; accepted bodies remain byte-exact. Regressions (13): real-HMAC correctly-signed delivery verifies and dispatches end-to-end; wrong signature 401s; byte-exact transport (mocked-accept, labeled); oversized declared length; continuing-upload client (exactly one 413, connection: close, no rawBody, no data listener); oversized chunked stream cut mid-read; header-less oversized → 413 not 400; at-cap boundary passes; stream error aborts via next(err) once; mid-stream single-413; LATE stream errors after BOTH rejection paths swallowed (no uncaught throw, one response, no next, swallow listener removed); clean end after rejection removes the swallow listener. The 120/min API rate limiter is NOT applied to webhooks (GitHub delivery reliability); a webhook-specific limiter remains a separate design decision. Signed-off-by: Alajmah <55954113+Alajmah@users.noreply.github.com>
|
/gitwire run review |
|
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1a1b220aba
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // verification, JSON parsing, or dispatch. | ||
| const WEBHOOK_MAX_BODY_BYTES = 25 * 1024 * 1024; | ||
|
|
||
| export function express_raw_body_middleware() { |
There was a problem hiding this comment.
Recreate the commit with the required DCO sign-off
The reviewed commit message contains no Signed-off-by: trailer, despite the repository requiring every commit to be created with git commit -s; this leaves the commit noncompliant and can block a DCO-gated merge, so recreate it with the required sign-off before acceptance.
AGENTS.md reference: AGENTS.md:L204-L209
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
🤖 AI Code Review — ✅ Approved
Confidence: high · Findings: 3
AI judgment: APPROVE · Evidence: COMPLETE · Authority: advisory
Evidence complete · 2/2 changed files accounted for
Other findings (3)
- [low] Declared-length rejection path removes ALL req listeners, contradicting the 'own listeners only' contract
- [low] 413 drain path may lack a deadline or drained-bytes cap, letting slow clients pin sockets
⚠️ unverified - [low] Swallowed late drain errors are fully silent, defeating the PR's own 'explicit disposition' goal operationally
⚠️ unverified
🔮 Devil's Advocate (2 turns): 2 missed risks found · 1 upheld
GitWire AI Review Gate (bundle-driven v2) · Structured schema · Scope-validated · Devil's Advocate · AI recommendation — maintainers and repository policy retain authority
Finding details (not annotatable inline)
-
[LOW] 413 drain path may lack a deadline or drained-bytes cap, letting slow clients pin sockets
The declared-length rejection path drains the oversized body to completion after committing the 413. A hostile or broken client that trickles bytes can keep the socket, the attached drain handlers, and the swallow listener alive for an attacker-controlled window. Node >=18's default server.requestTimeout bounds this, but deployments commonly override it (or run older Node), and the review did not verify a timeout, destroyed-bytes cap, or socket.setTimeout on the drain. Standard mitigation is to destroy after N seconds or N drained bytes; the review evaluated the listener contract but not the drain's termination guarantee.
-
[LOW] Swallowed late drain errors are fully silent, defeating the PR's own 'explicit disposition' goal operationally
The PR title promises explicit disposition of late errors, but if the swallow listener is a pure no-op, operators cannot distinguish routine client disconnects (benign and expected at webhook volume) from abnormal patterns such as a proxy consistently resetting mid-drain — which can signal real infrastructure trouble. A debug-level log line or a late-error-after-413 counter costs nothing and preserves the explicitness intent. The review scrutinized the listener contract but never assessed observability of the new swallowing path.
| // listener, so nothing can buffer. | ||
| res.setHeader("connection", "close"); | ||
| res.status(413).json({ error: "Payload too large" }); | ||
| req.removeAllListeners("data"); |
There was a problem hiding this comment.
[LOW] Declared-length rejection path removes ALL req listeners, contradicting the 'own listeners only' contract
The declared Content-Length path calls req.removeAllListeners('data'/'end'/'error') before draining. This directly conflicts with the in-code contract a few lines above ('Own listeners only; other components' handlers are never touched'): any listener attached by an earlier middleware (e.g., metrics/tracing that finalizes on 'end' or 'error') is silently discarded, so its cleanup would never run for that request — the late error would instead hit the no-op swallow listener. Because this only happens after the 413 is committed and the request is being discarded, practical impact is minimal, but either document the blanket removal as intentional (with the reason) or restrict it to removing this middleware's own handlers, mirroring the streaming path's detach() approach for consistency.
|
✅ GitWire: A review is already published for this head — no new review was posted. Outcome: APPROVE. |
Adjudication — GitWire AI Review @ 1a1b220 (APPROVED, high confidence, 3 findings)Disposition: none blocking; both lows answered.
Gate state: all 21 checks green, |
|
Superseded by the v4 PR: blanket removeAllListeners removed from the declared-length path, with the pre-existing-listener preservation regression. |
Final branch of Unit A (supersedes #447 → #450; branch updates ruleset-refused). Carries the required stream-error correction on top of everything prior:
The correction: late stream errors after rejection are swallowed
Both rejection paths resume the stream after committing the 413 — and a resumed Node stream with no error listener emits an uncaught
errorevent if the socket dies mid-drain. Your finding was correct; the prior adjudication (leaning on HTTP-server socket ownership) was wrong at the EventEmitter layer. Each rejection now attaches its own no-op error listener before resuming, removed on end or error: own listeners only, other components' handlers untouched, andnext()is never called after the 413 commits.Regressions (3 new): late stream error after the declared-length 413 — swallowed, exactly one response, no
next(), swallow listener removed; late stream error after the mid-stream 413 — same; clean end after the mid-stream 413 also removes the listener (no leak). The two prior post-rejection zero-listener assertions now pin the deliberate transient swallow listener instead of asserting its absence.Everything from #450 stands
Streaming actual-byte enforcement; 25 × 1024 × 1024 = 26,214,400 bytes exactly (GitHub's ceiling); declared-length early-out with the same explicit disposition (
connection: close, listener removal, drain — nothing buffers however long the peer transmits, regression included); real-HMAC signed-delivery regression (true HMAC-SHA256: correct signature → 202 + dispatch, wrong → 401); continuing-upload regression; chunked mid-read cutoff; header-less oversized → 413 not 400; at-cap boundary; single-413 semantics. 13 tests.Holding at the merge gate — exact head
1a1b220abaaeb5ddbb0f3768a48be91c0cec5b1a. CodeQL #10's alert state awaits deploy + post-merge analysis.