fix(webhooks): pin delivery to validated DNS#1
Open
michael-schvarcz wants to merge 1 commit into
Conversation
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.
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:
Ran:
npx vitest run tests/webhook-url-validation.test.ts tests/webhook-delivery-security.unit.test.ts tests/webhook-delivery-redirect.unit.test.tsnpx 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.tsgit diff --checkNote: repo-wide
npx vue-tsc --noEmitstill stops on unrelated existing CLI workspace errors (@capgo/cli/sdkresolution and one implicit-any in CLI tests), but the webhook/IP errors found during the first run were fixed.