forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 19
PS: Add ZipSlip query #287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
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
f467de0 to
ca20eb5
Compare
LWSimpkins
requested changes
Sep 24, 2025
powershell/ql/lib/semmle/code/powershell/security/ZipSlipCustomizations.qll
Outdated
Show resolved
Hide resolved
LWSimpkins
approved these changes
Sep 24, 2025
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.
This PR adds another classic query: finding zip slip vulnerabilities.
The query works in the sense that it does find what its supposed to find. i.e., it detects:
However, because we haven't added support for proper barriers guards to PowerShell we currently also flags this false positive:
I'll use this motivation to start working on proper barrier guard support for PowerShell soon. That should be relatively easy now that GitHub has added a shared guards library.
Commit-by-commit review recommended. It took quite a lot of small improvement in various internal libraries to get this working. In particular:
zip.Entitiesas a flow source.I then discovered a bug in the control-flow class for
foreach: the predicate for getting the "iterable" part of aforeach(i.e,xsinforeach(x in xs) { ... }) didn't work because it has some special handling in the control-flow graph. So 831f25d adds a test for this and 2ec78ed fixes this.I then discovered another bug around
foreachloops: we didn't have a read step fromxstoxin:So 4276405 adds a test for this and 5692eb0 fixes this.
And finally the query now detects the required cases as demonstrated by 93a3833 🎉
Along the way I also did a drive-by improvement to
DataFlow::ObjectCreationNodein ca20eb5. This was needed for an earlier version of the query, but ended up not being necessary in the end. It is still a valuable change, though.