Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Null-containing allowlists can incorrectly sanitize URI hosts and suppress genuine security alerts.
1 open finding
What changed in this PR
Extends Java’s default taint sanitizers to recognize constant string comparisons and shares that logic with URI host validation.
Changes:
- Adds
equalsandequalsIgnoreCaseconstant guards. - Reuses shared guards for SSRF and redirect checks.
- Expands regression coverage and documents the behavior.
| File | Description |
|---|---|
| java/ql/test/query-tests/security/CWE-918/RequestForgery.expected | Updates SSRF expectations. |
| java/ql/test/query-tests/security/CWE-918/HostComparison.java | Adds collection host-check cases. |
| java/ql/test/query-tests/security/CWE-601/semmle/tests/UrlRedirect.expected | Updates redirect expectations. |
| java/ql/test/query-tests/security/CWE-601/semmle/tests/HostComparisonRedirect.java | Adds collection redirect cases. |
| java/ql/test/library-tests/listofconstants/test.expected | Removes relocated expectations. |
| java/ql/test/library-tests/listofconstants/CONSISTENCY/typeParametersInScope.expected | Removes relocated consistency output. |
| java/ql/test/library-tests/default-taint-sanitizer/test.ql | Queries default sanitizers. |
| java/ql/test/library-tests/default-taint-sanitizer/test.expected | Records sanitizer expectations. |
| java/ql/test/library-tests/default-taint-sanitizer/ConstantValue.java | Adds equality guard cases. |
| java/ql/test/library-tests/default-taint-sanitizer/CONSISTENCY/typeParametersInScope.expected | Relocates consistency output. |
| java/ql/lib/semmle/code/java/security/RequestForgery.qll | Reuses shared host guards. |
| java/ql/lib/semmle/code/java/security/ConstantValueSanitizer.qll | Generalizes constant-value guards. |
| java/ql/lib/semmle/code/java/dataflow/FlowSteps.qll | Imports the renamed sanitizer. |
| java/ql/lib/change-notes/2026-10-14-constant-value-guards.md | Documents analysis improvements. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+154
to
155
| constantValueGuardChecks(guard, checked, branch) and | ||
| e = getCheckedHost(checked).getQualifier() |
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.

Extend the default Java taint sanitizer for constant allowlists to recognize direct
String.equalsandString.equalsIgnoreCasecomparisons against compile-time constants. These checks are treated as singleton allowlists and benefit all Java taint-tracking queries.This sanitizer was already in use as a generalized constant-value guard in the URI host sanitizer for
java/ssrfandjava/unvalidated-url-redirection. They have been refactored to use the shared implementation.