fix(webhooks): block SSRF targets on outbound delivery#1332
Merged
iammukeshm merged 2 commits intoJul 13, 2026
Merged
Conversation
Webhook subscriptions take a tenant-supplied destination URL, so the target is untrusted input. The create validator only checked "absolute URI + http/https scheme", and both delivery sinks (WebhookDeliveryService, WebhookDispatchJob) POSTed to new Uri(url) with AllowAutoRedirect=true and no address screening. Any authenticated tenant with Webhooks.Create could register 169.254.169.254, loopback, or an RFC1918 host and use the delivery log as a blind-SSRF oracle. - WebhookUrlGuard: central screen for loopback / link-local (cloud metadata) / RFC1918 / CGNAT / IPv6 ULA, plus "localhost". - Validator rejects blocked hosts at the create boundary (fast feedback). - "Webhooks" HttpClient: SocketsHttpHandler with AllowAutoRedirect=false and a ConnectCallback that screens the resolved IP at connect time, closing the DNS-rebinding window left by a create-time hostname check. One handler guards both sinks (shared named client).
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
…ailure test The dispatch-job test created a subscription pointing at https://127.0.0.1:1 to simulate an unreachable endpoint, but the new SSRF create guard correctly rejects loopback targets, so the create returned 400. Switch to a .invalid host, which never resolves (fast transient failure at DNS) and passes the create guard like any public hostname — same test intent, compatible with the egress guard.
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.
Problem
Webhook subscriptions accept a tenant-supplied destination URL, so the target is untrusted input. The create validator (
CreateWebhookSubscriptionCommandValidator) only enforced absolute URI + http/https scheme, and both delivery sinks —WebhookDeliveryServiceandWebhookDispatchJob— POSTed tonew Uri(subscription.Url)withAllowAutoRedirect=trueand no address screening.Any authenticated tenant holding the ordinary
Webhooks.Createpermission could registerhttp://169.254.169.254/…(cloud instance metadata),http://127.0.0.1/…, or an RFC1918 host. The delivery log records the status code / error, turning it into a blind-SSRF oracle.Fix
WebhookUrlGuard— one place that screens loopback, link-local (169.254/16, cloud metadata), RFC1918, carrier-grade NAT (100.64/10), IPv6 loopback/link-local/unique-local, andlocalhost.WebhooksnamedHttpClientuses aSocketsHttpHandlerwithAllowAutoRedirect=falseand aConnectCallbackthat screens the resolved IP at connect time. This closes the DNS-rebinding window a create-time hostname check leaves open, and a single handler covers both sinks (they share the named client).Tests
CreateWebhookSubscriptionSsrfValidatorTests— the four SSRF URLs are rejected, a public HTTPS URL passes, andIsBlockedAddressis covered across IPv4/IPv6 ranges. FullWebhooks.Testssuite green (69/69).Notes
Docs changelog entry to follow in the docs repo.