You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Java: Require related values in composite PathSanitizer guards - #23290
Require composite path-injection sanitizers (allowedPrefixGuard, dotDotCheckGuard, and blockListGuard) to connect the expression being sanitized and the expression checked by the dominating complementary guard via local taint flow, preventing unrelated prefix or '..' checks in the same method from acting as sanitizers.
Also strip casts and Kotlin not-null assertions via getUnderlyingExpr() in the StringSubstringMatch branches of BlockListGuard and PathTraversalGuard.
Require composite path-injection sanitizers (allowedPrefixGuard,
dotDotCheckGuard, and blockListGuard) to connect the expression being
sanitized and the expression checked by the dominating complementary
guard via local taint flow, preventing unrelated prefix or '..' checks
in the same method from acting as sanitizers.
Also strip casts and Kotlin not-null assertions via getUnderlyingExpr()
in the StringSubstringMatch branches of BlockListGuard and
PathTraversalGuard.
Fixesgithub#23281.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The sanitizer still suppresses path-traversal alerts after lossy conversions and introduces false positives for check-preserving conversions, with regression coverage missing both cases.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The sanitizer can mark paths as safe despite unchecked attacker-controlled components or checks on lossy-derived values, causing real path traversal vulnerabilities to be missed.
Safe paths can now be reported when the complementary guard uses FileSystem.getPath, Path.toAbsolutePath, or File.getAbsolutePath, because these taint-only conversions are missing from the backward relation. For example, precomputing checked = FileSystems.getDefault().getPath(source) and target = source + "/file" before checking checked.startsWith("/safe") && !target.contains("..") no longer sanitizes target. Include these conversions and add regression cases, keeping the single-string/empty-varargs restriction for getPath.
Precomputing File file = new File(dir, name) before !name.contains("..") && file.toPath().startsWith(dir.toPath()) now loses sanitization and can produce a false alert. The child-to-File edge exists only in FileConstructorChildArgumentStep, which FlowToPathGuard::hasFlow does not follow. Include that edge in the forward relation and add a precomputed-constructor regression case.
Allow localFlowToPathGuard to step backwards across String/File/Path
representation conversions (including FileSystem.getPath,
Path.toAbsolutePath, File.getAbsolutePath, and File.getAbsoluteFile),
and allow flowsFromGuard to traverse File(parent, child) child
arguments so precomputed derived paths remain sanitized when paired with
a guard on the base value.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
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.
Require composite path-injection sanitizers (allowedPrefixGuard, dotDotCheckGuard, and blockListGuard) to connect the expression being sanitized and the expression checked by the dominating complementary guard via local taint flow, preventing unrelated prefix or '..' checks in the same method from acting as sanitizers.
Also strip casts and Kotlin not-null assertions via getUnderlyingExpr() in the StringSubstringMatch branches of BlockListGuard and PathTraversalGuard.
Fixes #23281.