Go: Fix incorrect path injection sanitizer FilePath.Rel#22150
Open
owen-mc wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a long-standing incorrect Go path-injection/ZipSlip sanitization model for path/filepath.Rel, which previously suppressed legitimate path-traversal findings by treating Rel (and an err == nil pattern around it) as a sanitizer.
Changes:
- Remove the
barrierModelentry that treatedfilepath.Rel’s return value as apath-injectionbarrier. - Remove the
TaintedPathcustomization that treatederr == nilfromfilepath.Rel(base, path)as a containment/sanitizer guard. - Update the CWE-022 test cases and
.expectedoutputs to reflect the newly-detected flows, and add a changenote documenting the analysis impact.
Show a summary per file
| File | Description |
|---|---|
| go/ql/lib/ext/path.filepath.model.yml | Removes the incorrect barrier model for filepath.Rel while keeping taint propagation. |
| go/ql/lib/semmle/go/security/TaintedPathCustomizations.qll | Drops the Rel-based “containment” sanitizer guard that caused false negatives. |
| go/ql/test/query-tests/Security/CWE-022/TaintedPath.go | Updates inline expectations to mark filepath.Rel usage as unsafe where appropriate. |
| go/ql/test/query-tests/Security/CWE-022/TaintedPath.expected | Updates expected results to include the newly surfaced go/path-injection alert paths. |
| go/ql/test/query-tests/Security/CWE-022/tst.go | Updates ZipSlip test annotations to treat Rel-based containment as unsafe. |
| go/ql/test/query-tests/Security/CWE-022/ZipSlip.expected | Updates expected results to include the newly surfaced go/zipslip path(s). |
| go/ql/lib/change-notes/2026-07-09-remove-incorrect-path-sanitizer.md | Documents the modeling fix and the expected increase in results. |
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 0
- Review effort level: Low
Contributor
|
@owen-mc : Perhaps run DCA as well. |
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.
Reported in #22143. This mistake has been in the code for over 6 years, since the first commit of the CodeQL library for Go!