fix: reject symlinked scan result paths in PR reusable workflow - #137
Open
w1j0y wants to merge 1 commit into
Open
fix: reject symlinked scan result paths in PR reusable workflow#137w1j0y wants to merge 1 commit into
w1j0y wants to merge 1 commit into
Conversation
The PR reusable workflow writes the base scan to old-results.json, checks out the untrusted PR commit with git checkout -f, then writes the PR scan to new-results.json before comparing the two with the reporter. A pull request can add a symlink such as new-results.json -> old-results.json. Since the scanner and reporter write and read these paths with calls that follow symlinks, the PR scan output overwrites the base scan output, so the reporter compares the PR scan against itself and reports no newly introduced vulnerabilities. Add a guard step right after the untrusted checkout that refuses to continue if old-results.json, new-results.json, or the reporter output path is a symlink.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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.
Fixes #136.
Summary
The PR reusable workflow writes the base scan to
old-results.json, checks out the untrusted PR commit withgit checkout -f, then writes the PR scan tonew-results.jsonbefore comparing the two with the reporter. A pull request can add a symlink such asnew-results.json -> old-results.json. Since the scanner and reporter write and read these paths with calls that follow symlinks, the PR scan output overwrites the base scan output, so the reporter compares the PR scan against itself and reports no newly introduced vulnerabilities. Full detail and a standalone reproduction are in #136.Fix
Add a guard step right after the untrusted checkout that refuses to continue if
old-results.json,new-results.json, or the reporter output path is a symlink.Testing
I do not have a way to trigger this repository's CI on a fork branch before opening the PR, so I validated the guard logic locally with a shell reproduction outside GitHub Actions.
Case 1, malicious PR symlink: reproduced the
git checkout -fsequence from the issue, then ran the same guard logic used in the new workflow step. It correctly refused withRefusing to scan through a symlinked result path introduced by the pull request: new-results.jsonand exited non zero.Case 2, normal run with plain files: ran the same guard logic against ordinary
old-results.json,new-results.json, andresults.sariffiles. It passed without blocking, so the change should not affect a normal scan.This fix corresponds to a report originally submitted through Google's OSS VRP intake at g.co/vulnz. The triage response asked that it be coordinated here via a public issue and pull request, so filing accordingly.