fix(notifications): restrict push endpoints to known push services and bound dispatcher requests - #153
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
Conversation
…d bound dispatcher requests
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This was referenced Sep 3, 2026
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.
Summary
Closes the blind-SSRF / dispatcher-stall hole in web push: any authenticated hacker could
POST /v1/notifications/subscribewith an arbitraryendpoint(onlyvalidate:"url"applied), and the dispatcher would later POST to it with webpush-go's default&http.Client{}— no timeout, follows redirects, sequential loop — so one endpoint that accepts a TCP connection and never replies froze push delivery for the rest of the event.Endpoint allowlist (
cmd/api/push_endpoint.go)fcm.googleapis.com,android.googleapis.com,push.services.mozilla.com,push.apple.com,notify.windows.com,push.samsungosp.com(Chrome/Edge/Brave/Opera, Firefox, Safari, WNS, Samsung Internet).PUSH_ENDPOINT_ALLOWED_HOSTS(comma-separated) →config.vapid.allowedEndpointHosts. Documented in.env.example.subscribePushHandlerreturns 400 for anything off the list.deliverNotificationre-checks each stored sub before sending and prunes disallowed rows (covers rows written before this change) without ever contacting them. Pruned rows don't count toward the all-auth-failed mass-delete guard.Bounded HTTP client (
newPushHTTPClient, injected aswebpush.Options.HTTPClientviaapp.pushClient)Timeout: 10s(covers connect → body read),CheckRedirectreturnshttp.ErrUseLastResponse, response body drain capped at 64 KiB.Tests: dispatcher tests now use
httptest.NewTLSServerwith127.0.0.1allowlisted and the server's client injected. New cases: disallowed endpoints pruned with zero requests made, redirects not followed, hanging endpoint returns within the client timeout; handler tests coverhttp://, private/link-local IPs, look-alike hosts, userinfo, and legitimate subdomains (updates.push.services.mozilla.com,web.push.apple.com,*.notify.windows.com).Verified:
gofmt -l .clean,go vet,go test ./cmd/api/ ./internal/...pass.Link to Devin session: https://app.devin.ai/sessions/7730c9bccc574233a0c2650ba204bec2
Open in Devin Desktop: https://app.devin.ai/desktop/session/7730c9bccc574233a0c2650ba204bec2?variant=devin
Requested by: @balebbae