Repository navigation
fix(alerts): resolve outbound URLs and enforce the policy at dispatch - #33439
Conversation
This comment has been minimized.
This comment has been minimized.
Code Review ✅ Approved 2 closed / 2 findings🔴 High risk · Outbound request policy now controls SSRF-sensitive dispatch across alert publishers Centralizes outbound URL enforcement at dispatch with host resolution before policy application, disabling redirect following and protecting sensitive webhook headers. Extends endpoint validation across create, PUT, and PATCH paths. Resolves only new or changed endpoints with cache-backed lookups, and abbreviated address literals like ✅ 2 closed✅ Performance: Entity save path now does synchronous DNS on every endpoint
Closed: Security: Literal 0.0.0.0 / :: no longer refused, reaching localhost
OptionsDisplay: compact → Counting what did not apply, without listing it. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
🚦 Removed from the merge queue —
|
Fixes #32592
URLValidatordecided whether an outbound URL was acceptable by pattern-matching the text of thehost, and never resolved it. So a name pointing at a cloud metadata endpoint went straight through.
It was also a call each caller had to remember to make: three of the four webhook publishers did not
make it, and PATCH and the non-
Externalcategories skipped the resource's check entirely.The scope follows the security model:
an administrator directing the server at a host they choose is intended behaviour, so this closes only
what that page calls a vulnerability, namely reaching a sphere the operator cannot and following a
redirect across hosts.
What changed
The decision now resolves the host and classifies the addresses behind it, and it runs where the
request leaves rather than where someone remembered to ask. A
ClientRequestFilteronSubscriptionUtil.getClientcovers all four publishers, andOAuth2TokenManagerand the governancewebhook sink now build their clients through that same factory, which is also where the sink picks up
the timeouts it was running without.
The rule has two tiers:
now makes it hold for every spelling:
127.1and[::ffff:10.0.0.1]reach the same places as127.0.0.1and10.0.0.1, so they are refused with them.themselves: a link-local address, or one of the metadata services the JDK does not classify. Those
are listed individually rather than by range, because
100.64.0.0/10is also Tailscale's range andrefusing it would break receivers reached that way.
A name resolving to this machine or to the cluster network stays allowed: connecting to destinations
an operator configures is what the product does, and refusing them would break in-cluster receivers
and local development alike.
The same policy runs in
EventSubscriptionRepository.prepare, so create, PUT and PATCH are covered.An endpoint already stored is left alone, so an upgrade cannot make an existing subscription
uneditable; the request it would produce is still refused at dispatch.
Redirects are no longer followed; the recorded status carries the
Location, so a failure still namesthe URL to move to. The two copies of the webhook header builder are now one.
What an existing deployment will notice
A receiver that answers with a redirect now fails instead of being followed. A hostname that resolves
to a link-local or cloud metadata address is refused. An internal address spelled unusually, such as
127.1or[fec0::1], is refused where the old pattern let it through.Host, hop-by-hop andcloud-metadata headers set on a webhook are dropped with a warning. The governance sink, previously
unbounded, is capped at 30s connect and 120s read. A receiver named by a macOS
.localname isrefused, because mDNS answers one with link-local interface addresses beside the routable one;
localhostis unaffected and remains the way to reach a receiver on the same machine.One thing that was refused starts working: a public host whose name merely begins like a private
range,
10.example.comsay, was matched by the old pattern on its text. Nothing else changes.Testing
The resolver is injected, so the suite never touches DNS and no harness has to weaken the policy to
reach its own stub server.
EventSubscriptionResourceITpins both halves:a loopback endpoint is refused on create, and refused again when a PATCH introduces one, the path that
reached no check before. Locally 246 integration and 69 unit tests pass, 0 failures.
Not in this change
DNS rebinding is narrowed, not closed. Pinning the connection to the validated address means changing
the JAX-RS connector, which would also drop the JVM proxy settings some deployments rely on.
🤖 Generated with Claude Code
The PR is not yet safe to merge because an outstanding outbound-policy defect and an explicit method-responsibility requirement remain unresolved.
Findings
Summary
This PR centralizes outbound URL enforcement at dispatch, resolves destination hosts before applying the policy, disables redirect following, protects sensitive webhook headers, and extends endpoint validation across create, PUT, and PATCH paths.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart LR Config[Subscription configuration] --> Save[Repository validation] Save --> Policy[Outbound URL policy] Dispatch[Webhook or OAuth dispatch] --> Client[Shared JAX-RS client] Client --> Filter[Request policy filter] Filter --> Policy Policy --> Resolve[Resolve destination host] Resolve --> Decision{Address permitted?} Decision -->|Yes| Send[Send without redirects] Decision -->|No| Block[Reject outbound request]Reviews (8) · Last reviewed commit: "fix(alerts): resolve the host as written..."