Skip to content

fix(webhooks): pin delivery to validated DNS#1

Open
michael-schvarcz wants to merge 1 commit into
cleberrafael:codex/harden-webhook-url-validationfrom
michael-schvarcz:codex/harden-webhook-url-validation-toctou
Open

fix(webhooks): pin delivery to validated DNS#1
michael-schvarcz wants to merge 1 commit into
cleberrafael:codex/harden-webhook-url-validationfrom
michael-schvarcz:codex/harden-webhook-url-validation-toctou

Conversation

@michael-schvarcz
Copy link
Copy Markdown

This applies the remaining DNS TOCTOU fix discussed on Cap-go#2200.

Webhook delivery now validates DNS and then pins the outbound TLS connection to one of the validated public IPs, while preserving the original hostname for SNI and the HTTP Host header. That removes the second runtime hostname resolution from the public delivery path, so a post-validation DNS rebind cannot steer the webhook POST to loopback, RFC1918, link-local, metadata, multicast, or other blocked private ranges.

Redirects remain manual/non-followed, so 3xx responses are not treated as successful deliveries.

Tests added/updated cover:

  • DNS rebinding regression: delivery connects to the validated IP and does not POST via runtime fetch
  • loopback, RFC1918, IPv4 link-local/metadata, reserved/multicast IPv4
  • IPv6 link-local, discard-only, NAT64, documentation, and multicast ranges
  • redirect responses are not followed or treated as success

Ran:

  • npx vitest run tests/webhook-url-validation.test.ts tests/webhook-delivery-security.unit.test.ts tests/webhook-delivery-redirect.unit.test.ts
  • npx eslint supabase/functions/_backend/utils/ip.ts supabase/functions/_backend/utils/webhook.ts tests/webhook-url-validation.test.ts tests/webhook-delivery-security.unit.test.ts tests/webhook-delivery-redirect.unit.test.ts
  • git diff --check

Note: repo-wide npx vue-tsc --noEmit still stops on unrelated existing CLI workspace errors (@capgo/cli/sdk resolution and one implicit-any in CLI tests), but the webhook/IP errors found during the first run were fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants