caelum0x 3cc4fd4caf fix: adversarial review of expansion — SSRF guard, webhook scoping, sweeper concurrency (294 tests)
Second adversarial review pass, this time over the expansion modules
(comments, webhooks, search, resolution, SDK). 9 findings, all verified real,
zero false positives:

- CRITICAL SSRF: the webhook dispatcher POSTed to any user-supplied URL,
  letting an authed caller hit cloud-metadata (169.254.169.254) and internal
  hosts, and use delivery outcome as a port-scan side channel. Added
  src/webhooks/ssrf.ts (blocks loopback/link-local/RFC-1918/metadata for IPv4,
  IPv6, and mapped forms) wired into webhook creation; residual DNS-rebinding
  risk documented.
- HIGH: new webhooks received events that predated their subscription (global
  high-water mark). Added per-subscription start_event_id with migration.
- HIGH: ResolutionSweeper had no concurrent-tick guard → duplicate AI calls
  when the provider is slow. Added the running-flag guard.
- MEDIUM: webhook-create rate limit (10/hr), atomic dispatcher writes,
  resolution force-flag body parsing without Content-Type; LOW: x402 signer
  browser base64 via TextEncoder.

tsc clean; 288 -> 294 tests.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-15 01:23:10 +03:00
..