🐛 Detect additional untrusted workflow contexts - #5152
Open
dhrrishitvdeka wants to merge 2 commits into
Open
Conversation
Signed-off-by: dhrrishitvdeka <dhrrishit@gmail.com>
dhrrishitvdeka
marked this pull request as ready for review
August 1, 2026 09:14
dhrrishitvdeka
requested review from
AdamKorcz and
spencerschrock
and removed request for
a team
August 1, 2026 09:14
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?
Patch fix for the Dangerous-Workflow check's script-injection detection.
What is the current behavior?
containsUntrustedContextPatterndoes not recognize several attacker-controlled event fields that GitHub's current CodeQL Actions model treats as untrusted. Workflows can therefore interpolate these values directly intorun:scripts without Scorecard reporting the script-injection risk.The uncovered fields include previous title, body, and head-ref values from edited events; merge-group refs and committer metadata; wiki-page titles; and workflow paths.
What is the new behavior (if this is a feature change)?
Dangerous-Workflow now detects:
github.event.pages[*].titlegithub.event.changes.title.fromgithub.event.changes.body.fromgithub.event.changes.head.ref.fromgithub.event.merge_group.head_refgithub.event.merge_group.committer.namegithub.event.merge_group.committer.emailgithub.event.workflow.pathgithub.event.workflow_run.pathgithub.event.workflow_run.referenced_workflows[*].pathTable-driven tests cover every new pattern and nearby trusted fields to guard against over-matching.
Which issue(s) this PR fixes
Towards #3915.
Special notes for your reviewer
The field list is derived from GitHub CodeQL's current untrusted event properties model. This scope intentionally excludes committer fields already proposed in #4968 and fork/workflow-run fields already proposed in #5127.
Validation:
go test ./checks/raw -run TestUntrustedContextVariables -count=1passes with Go 1.25.6.git diff --checkpasses.checks/rawpackage was attempted on Windows, but unrelated existing tests assume/tmppaths and panic inTestCollectGitHubActionsWorkflowPinning; Linux CI can exercise the full package.Does this PR introduce a user-facing change?
Repositories that interpolate these attacker-controlled fields directly into inline scripts will now be reported by Dangerous-Workflow.