🐛 Detect explicit unsafe fork checkouts - #5178
Draft
kyzzniko-lang wants to merge 1 commit into
Draft
Conversation
Signed-off-by: haoze ying <3246017002@stu.fafu.edu.cn>
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.
What kind of change does this PR introduce?
Bug fix for the Dangerous-Workflow check.
What is the current behavior?
A privileged
pull_request_targetworkflow can explicitly check out an external contributor's fork without being reported when it uses this combination:The current check recognizes references containing
github.event.pull_requestorgithub.event.workflow_run, but notgithub.head_refcombined with an attacker-controlled fork repository.What is the new behavior (if this is a feature change)?
Dangerous-Workflow reports the checkout when all three high-confidence indicators are present:
github.event.pull_request.head.repo.full_name;github.head_ref; andallow-unsafe-pr-checkoutinput is explicitlytrue.The narrow combination avoids reporting workflows that remain protected by checkout's safer default. Tests cover the unsafe combination, the protected default, a same-repository
head_ref, and the existing pull-request expression behavior.Which issue(s) this PR fixes
Towards #2404
Special notes for your reviewer
This is a draft pending maintainer feedback on the detection boundary. The focused tests pass locally on Go 1.25.6. The full
checks/rawpackage has pre-existing Windows path-related failures in pinned-dependency tests; those failures do not touch the modified files.Does this PR introduce a user-facing change?
Yes. Repositories with an explicitly unsafe fork checkout in a privileged workflow will receive a Dangerous-Workflow finding.