Reject dangerous URL schemes in UrlUtil.validateUrl - #4
Open
drdavella wants to merge 1 commit into
Open
Conversation
Add an explicit pre-check that rejects redirect targets whose scheme is javascript:, data:, vbscript:, or file:. ESAPI's isValidRedirectLocation generally catches these, but the current implementation first strips the request's own scheme/host/port from the URL before handing the remainder to ESAPI, which means a payload whose scheme differs from the request's scheme survives the strip and then depends entirely on ESAPI's regex to catch it. Rejecting these schemes up front is a small defense-in-depth step for the login and logout success handlers that call this method. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Great job! No new security vulnerabilities introduced in this pull requestCommunicate with Checkmarx by submitting a PR comment with @Checkmarx followed by one of the supported commands. Learn about the supported commands here. |
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
javascript:,data:,vbscript:, andfile:schemes toUrlUtil.validateUrl.Why
validateUrlcurrently trims the request's own scheme/host/port off the URL and hands the remainder toESAPI.validator().isValidRedirectLocation(...). If the attacker supplies a target whose scheme differs from the request's scheme (e.g.javascript:...on an HTTP request), the strip is a no-op and the payload survives into ESAPI, where correctness depends entirely on ESAPI's regex. Rejecting these schemes up front is a small defense-in-depth step for the login and logout success handlers that call this method (BroadleafAdminAuthenticationSuccessHandler,BroadleafAdminLogoutSuccessHandler,StaleStateProtectionServiceImpl).Test plan
mvn -pl common -am compile?targetUrl=javascript:alert(1)and confirm the 403 path fires/admin/...) still succeedNotes for reviewers
This tweaks the "URL validation for admin redirects" security control referenced in the repo threat model. The mitigations line should be extended — the redirect validator now blocks common non-http(s) exploit schemes as a pre-check, not just relies on ESAPI.
🤖 Generated with Claude Code