You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
security: bound attacker-controlled scan fan-out and rate-limit write race (#539)
* security: bound attacker-controlled scan fan-out and rate-limit write race
Hardens three DoS / race-condition findings surfaced by a deep security
audit and tracked as private draft advisories. All three are reachable by
an unauthenticated request and turn one cheap, rate-limited request into
disproportionate backend work.
- DKIM selector fan-out (GHSA-6fqp-4vhc-59mf): parseSelectors and the MCP
parseSelectorsFromArray now cap the custom selector list to 16 items and
63 chars each (RFC 1035 label limit) before analyzeDkim fires one DNS
lookup per selector. The MCP inputSchema advertises maxItems/maxLength to
match, but enforcement is server-side regardless (the schema is advisory).
- MTA-STS unbounded body (GHSA-p676-gc7j-96mx): fetchPolicy now reads the
policy via arrayBuffer() truncated to MAX_POLICY_BYTES (64KB), mirroring
the ceiling security-txt already applies, so an attacker-controlled
mta-sts.<domain> can't stream an unbounded body into the isolate. The
redirect:"manual" posture (RFC 8461 §3.3) is unchanged.
- Rate-limit counter write (GHSA-v7qc-7qh8-h69g): the Cache-API write is
awaited before returning instead of deferred via waitUntil, closing the
intra-isolate read-modify-write window the deferral widened. A fully
atomic cross-isolate counter (Durable Object / native binding) remains
tracked in the advisory and is out of scope here.
Also gitignores .security-scans/ so point-in-time scan reports are never
committed to this public repo.
Tests: 1305 passing, 0 failing. Typecheck + biome lint clean. Adds
regression tests for each cap and for the awaited rate-limit write.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: schmug <38227427+schmug@users.noreply.github.com>
* security: scope this PR to the per-analyzer DoS caps; drop the rate-limit write-race fix (superseded by #549)
The Cache-API await fix here (GHSA-v7qc-7qh8-h69g) is only a partial mitigation; #549 fully supersedes it with an atomic Durable Object rate limiter and deletes the checkRateLimitCache path this touched. Revert the rate-limit.ts change, the rateLimitMiddleware hunk in index.ts, and the f30 test so this PR scopes cleanly to the per-analyzer caps that nothing else duplicates: DKIM selector count/length (GHSA-6fqp-4vhc-59mf) and MTA-STS policy body size (GHSA-p676-gc7j-96mx). Avoids a same-line conflict with #549's middleware rewrite.
Signed-off-by: schmug <38227427+schmug@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Signed-off-by: schmug <38227427+schmug@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments