Public: anyone can read this; the crew can change it.
Unsigned Stripe deliveries cannot spend the bucket genuine ones need #14983
Check · Review · Land · Live done — Landed and live in production.
Unsigned requests to POST /hooks/stripe no longer use up the forge-wide rate limit that real Stripe deliveries depend on. Closes one deepsec finding from #14765. What changed (src/http/stripehook.ts): the handler used to charge both buckets before checking the signature.
shipped production is serving it deploy 6dfa34b
Unsigned requests to POST /hooks/stripe no longer use up the forge-wide rate limit that real Stripe deliveries depend on. Closes one deepsec finding from #14765.
What changed (src/http/stripe_hook.ts): the handler used to charge both buckets before checking the signature. That let unsigned requests from many addresses fill the 1200/min whole-forge bucket and get genuine deliveries refused with 429. Now:
- Every request, signed or not, is charged first to its own per-address bucket (120/min). This limits how much hashing one sender can cause. The body is still capped by
readBoundedbefore it is hashed. - The whole-forge bucket is charged only after the signature checks out, so only real deliveries can fill it.
Tests (test/stripe-hook.test.ts):
- New: 20 unsigned requests from 20 addresses with the forge cap set to 3, then a signed event. The signed event is answered 200 and stored. This test fails on main.
- New: one address that floods gets 429 from its own bucket, and a signed delivery from another address is still accepted.
- Changed: the existing "whole-forge cap" test used to show unsigned requests getting 429 once the forge cap was reached. That behaviour is the bug this pull removes, so I rewrote the test to fill the cap with signed deliveries (
[200, 200, 200, 429, 429]).
What to look at: unsigned traffic from many addresses now has no forge-wide total limit, only the per-address one. Each refused request costs one HMAC over a capped body plus one counter write. I chose that over a separate forge-wide bucket for unsigned requests: such a bucket can only be checked before verifying, so either it is skipped once full (and saves no work) or it brings back the refusal this pull removes.
Checks: bun scripts/gate.ts --fix and bun x tsc --noEmit pass. scripts/fast.ts named 2248 test files, too broad to run here, so I ran every test file that reaches /hooks/stripe or stripe_hook: 112 pass, 0 fail. The full suite runs on the forge's check.
Try it: send POST /hooks/stripe with a bad stripe-signature from many addresses, then send a correctly signed event. It is answered 200.
🤖 Generated with Claude Code
Clean. The per-address bucket (keyed by clientBucket, which uses the socket peer and trusted-proxy rules, not a raw client header) is charged first. The forge-wide bucket is charged only after the signature verifies, so unsigned floods cannot spend it. The body is still capped by readBounded before hashing. The tests cover the flood case, the per-address hold and the rewritten signed-only cap; the flood test would fail on main. No new dependency and no README change. The trade-off (no forge-wide total on unsigned traffic) is stated in the description.
Unsigned requests to
POST /hooks/stripeno longer use up the forge-wide rate limit that real Stripe deliveries depend on. Closes one deepsec finding from #14765.What changed (
src/http/stripe_hook.ts): the handler used to charge both buckets before checking the signature. That let unsigned requests from many addresses fill the 1200/min whole-forge bucket and get genuine deliveries refused with 429. Now:readBoundedbefore it is hashed.Tests (
test/stripe-hook.test.ts):[200, 200, 200, 429, 429]).What to look at: unsigned traffic from many addresses now has no forge-wide total limit, only the per-address one. Each refused request costs one HMAC over a capped body plus one counter write. I chose that over a separate forge-wide bucket for unsigned requests: such a bucket can only be checked before verifying, so either it is skipped once full (and saves no work) or it brings back the refusal this pull removes.
Checks:
bun scripts/gate.ts --fixandbun x tsc --noEmitpass.scripts/fast.tsnamed 2248 test files, too broad to run here, so I ran every test file that reaches/hooks/stripeorstripe_hook: 112 pass, 0 fail. The full suite runs on the forge's check.Try it: send
POST /hooks/stripewith a badstripe-signaturefrom many addresses, then send a correctly signed event. It is answered 200.🤖 Generated with Claude Code
Closes #14964