Skip to content

[Improve] Add SSRF protection for user-configured webhook URLs - #4386

Open
osasukev57-venn wants to merge 1 commit into
apache:masterfrom
osasukev57-venn:fix/ssrf-webhook-validation
Open

osasukev57-venn wants to merge 1 commit into
apache:masterfrom
osasukev57-venn:fix/ssrf-webhook-validation

Conversation

@osasukev57-venn

Copy link
Copy Markdown

What changes were proposed in this pull request?

Fixes #4383

Add SSRF protection for user-configured webhook/notification URLs.

Changes

  1. New InternalUrlValidator utility in hertzbeat-common-core:

    • Restricts URL scheme to http / https
    • Resolves the host and rejects loopback / link-local / RFC-1918 / ULA / reserved addresses
    • Checks all resolved IPs (DNS may return multiple)
    • Fails closed on DNS resolution failure
  2. Apply validation before sending in three notify handlers:

    • WebHookAlertNotifyHandlerImpl — user-supplied hookUrl
    • GotifyAlertNotifyHandlerImpl — configured gotifyWebhookUrl
    • NtfyAlertNotifyHandlerImpl — user-configured ntfyServerUrl
  3. Unit tests covering loopback, private, link-local, ULA, reserved, and public addresses.

Why is this needed?

User-supplied webhook URLs were only checked for non-blank, allowing server-side requests to internal services (e.g. cloud metadata 169.254.169.254, localhost APIs). ASF security assessed this as hardening under the trusted-user model, not a vulnerability.

How was this patch tested?

  • Unit tests for InternalUrlValidator (30+ cases)
  • Code review: all three handlers now call InternalUrlValidator.validate() before restTemplate.postForEntity()

Note on redirects

This PR adds pre-flight URL validation. Redirect-time re-validation can be added in a follow-up via a custom ClientHttpRequestFactory if maintainers request it.

Add InternalUrlValidator to common-core that rejects loopback, link-local,
RFC-1918, ULA and reserved addresses, and restricts scheme to http/https.
Apply validation before sending in WebHook, Gotify and Ntfy notify handlers.

Refs: apache#4383

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hardening: block SSRF to internal ranges on user-configured webhook/notification URLs

1 participant