[Improve] Add SSRF protection for user-configured webhook URLs - #4386
Open
osasukev57-venn wants to merge 1 commit into
Open
osasukev57-venn wants to merge 1 commit into
osasukev57-venn wants to merge 1 commit into
Conversation
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
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.
What changes were proposed in this pull request?
Fixes #4383
Add SSRF protection for user-configured webhook/notification URLs.
Changes
New
InternalUrlValidatorutility inhertzbeat-common-core:http/httpsApply validation before sending in three notify handlers:
WebHookAlertNotifyHandlerImpl— user-suppliedhookUrlGotifyAlertNotifyHandlerImpl— configuredgotifyWebhookUrlNtfyAlertNotifyHandlerImpl— user-configuredntfyServerUrlUnit 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?
InternalUrlValidator(30+ cases)InternalUrlValidator.validate()beforerestTemplate.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
ClientHttpRequestFactoryif maintainers request it.