Skip to content

fix(alerts): resolve outbound URLs and enforce the policy at dispatch - #33439

Merged
manerow merged 9 commits into
mainfrom
fix/32592-outbound-url-policy
Sep 21, 2026
Merged

manerow merged 9 commits into
mainfrom
fix/32592-outbound-url-policy

Conversation

@manerow

@manerow manerow commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #32592

URLValidator decided whether an outbound URL was acceptable by pattern-matching the text of the
host, 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-External categories 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 ClientRequestFilter on
SubscriptionUtil.getClient covers all four publishers, and OAuth2TokenManager and the governance
webhook 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:

  • A host written as an address keeps the rule it has today, and parsing rather than regex-matching
    now makes it hold for every spelling: 127.1 and [::ffff:10.0.0.1] reach the same places as
    127.0.0.1 and 10.0.0.1, so they are refused with them.
  • A host written as a name is refused only when it leads somewhere the operator cannot reach as
    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/10 is also Tailscale's range and
    refusing 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 names
the 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.1 or [fec0::1], is refused where the old pattern let it through. Host, hop-by-hop and
cloud-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 .local name is
refused, because mDNS answers one with link-local interface addresses beside the routable one;
localhost is 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.com say, 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. EventSubscriptionResourceIT pins 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

RetriggerConfidence Score: 4/5

The PR is not yet safe to merge because an outstanding outbound-policy defect and an explicit method-responsibility requirement remain unresolved.

Findings

  1. P1 Security Private Interface SSRF Bypass ▶
  2. P2 Methods Have Too Many Roles ▶
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.

  • Adds a shared outbound URL policy and JAX-RS request filter.
  • Routes webhook, OAuth token, and governance sink clients through the protected client factory.
  • Consolidates webhook header handling and adds protected-header filtering.
  • Adds unit and integration coverage for resolved destinations and persistence paths.
  • The latest revision preserves hostname case during resolution and adds mixed-case coverage.
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]
Loading

Reviews (8) · Last reviewed commit: "fix(alerts): resolve the host as written..."

@manerow
manerow requested a review from a team as a code owner September 16, 2026 18:06
@manerow manerow added backend area:alerts-notifications Change events, event subscriptions, alerts, notification templates and channels, email. safe to test Add this label to run secure Github workflows on PRs labels Sep 16, 2026
@greptile-apps

This comment has been minimized.

@gitar-bot

gitar-bot Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
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 127.1 are now correctly refused alongside standard notation. No issues remain.

✅ 2 closed
✅ Performance: Entity save path now does synchronous DNS on every endpoint

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EventSubscriptionRepository.java:163-170 📄 openmetadata-service/src/main/java/org/openmetadata/service/util/OutboundUrlPolicy.java:76-90
validateDestinationEndpoints in prepare now calls URLValidator.validateURL → OutboundUrlPolicy.checkForSave, which performs a real, blocking DNS lookup (InetAddress.getAllByName) for each webhook destination. prepare runs on the JAX-RS request thread during create/PUT/PATCH, so a subscription with several destinations, or a hostname served by a slow/unresponsive DNS resolver, blocks the request thread for up to the OS resolver timeout per host (the previous regex check did no network I/O). The connect-time filter already re-validates at dispatch, so the save-time lookup is defense-in-depth rather than the guard. Consider bounding the impact (e.g. cap the number of destinations resolved, or rely on the connect-time check) so a slow DNS response cannot stall alert create/update requests.

Closed: Security: Literal 0.0.0.0 / :: no longer refused, reaching localhost

📄 openmetadata-service/src/main/java/org/openmetadata/service/util/OutboundUrlPolicy.java:127-135
The rewrite of addressRejection replaced isLocalAddress (which was isLoopbackAddress || isLinkLocalAddress || isAnyLocalAddress) with an explicit literal check of only address.isLoopbackAddress() || isPrivateAddress(address). The unspecified/any-local addresses 0.0.0.0 and :: are neither loopback, link-local, nor site-local (verified), so a literal URL such as http://0.0.0.0:8585 or http://[::]:8585 now passes the policy. Connecting to 0.0.0.0 reaches the local host on Linux, which is exactly the case the deleted comment warned would be reopened ('connecting to 0.0.0.0 or :: reaches the local host, so leaving it out would reopen the case this rejects'). This also contradicts the PR's stated contract that a host written as an address keeps its existing rule, since these literals were previously refused. Restore the any-local check on the literal branch.

Review coverage

📋 Rules No rules evaluated

🧪 Functional validation Not enabled · Set up

🤖 Auto-approval Not enabled · Set up

Options

Display: compact → Counting what did not apply, without listing it.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@github-actions

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-09-21T18:32:17Z)

Blocked the queue: integration-tests-mysql-elasticsearch

This branch was previously deployed

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

Labels

area:alerts-notifications Change events, event subscriptions, alerts, notification templates and channels, email. backend safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Outbound URL policy is enforced inconsistently across webhook paths

3 participants