feat(dashboard): add size and rate limits with structured rejection logs to webhook endpoint - #274
Merged
Lakes41 merged 2 commits intoJul 24, 2026
Conversation
added 2 commits
July 24, 2026 00:40
This was referenced Jul 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #260
Stacked on #273 (main does not build at HEAD; this branches from the repaired tree). Happy to rebase once #273 merges.
The webhook route now rejects abuse before spending CPU on HMAC verification:
WEBHOOK_MAX_BODY_BYTES(default 256 KB) get a 413, checked against both the declaredcontent-lengthand the actual body, since the header can be absent or lying.x-forwarded-forentry, elsex-real-ip) that fails verification more thanWEBHOOK_INVALID_ATTEMPT_LIMITtimes (default 10) insideWEBHOOK_RATE_LIMIT_WINDOW_MS(default 60s) gets a 429 until the sliding window expires. A successful verification clears the source's window, so a legitimate sender with one bad clock sync is not punished. Limiter is in-process, noted in SECURITY.md that multi-instance deployments should back it with shared storage.console.warnwith areasonenum (oversized_payload,invalid_signature,expired_timestamp,rate_limited,malformed_header), source, endpoint, status, and timestamp. The log never contains the secret, the signature header, or the body; there is a test asserting exactly that.New module is
apps/dashboard/lib/webhooks/abuse-guard.ts; the route diff is small. SECURITY.md documents the limits and log format, and the webhook-utils README best-practices section points at it, since the guards live in the route rather than the package.Verification (watched locally):
npx tsx --test test/webhook-abuse.test.ts— 14/14 pass, covering 413 on declared and actual size, 429 after repeated invalid signatures, per-source isolation, reset-on-success, expired-timestamp classification, and log hygiene.npx tsx --test 'test/**/*.test.ts'— 592/592 pass.tsc --noEmit(5.6.3) — no new findings.