-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Actions: ActorIfCheck ControlCheck model fix for events that don't populate the checked field
#22368
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
Open
computersarebad
wants to merge
4
commits into
github:main
Choose a base branch
from
computersarebad:actor-if-check-event-validity
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Actions: ActorIfCheck ControlCheck model fix for events that don't populate the checked field
#22368
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9251d21
Actions: ActorIfCheck should not protect events that do not populate …
computersarebad 3048f47
Split payload-field actor checks into EventActorIfCheck
computersarebad e9d9d3a
Simplify EventActorIfCheck by binding context_prefix as a field
computersarebad dc6ee11
Add test coverage for sender, head_commit and commits checks
computersarebad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
actions/ql/lib/change-notes/2026-08-17-actor-if-check-event-validity.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| category: minorAnalysis | ||
| --- | ||
| * Checks on actor fields read from the event payload (e.g. `github.event.pull_request.user.login`) now only count as protection for events whose payload actually populates that field. These checks were split out of `ActorIfCheck` into a new class `EventActorIfCheck`, and `ActorIfCheck` now only covers `github.actor` and `github.triggering_actor`. Previously, a condition such as `github.event.pull_request.user.login != 'name'` on a workflow triggered by `issues` events was treated as a protective check even though `github.event.pull_request` is not populated for `issues` events, which makes the condition vacuous. This change will result in more results being found by the queries that rely on control checks, such as `actions/code-injection/critical`. |
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
12 changes: 12 additions & 0 deletions
12
actions/ql/test/query-tests/Security/CWE-094/.github/workflows/actor_check_valid_event.yml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| on: | ||
| pull_request_target: | ||
| types: [opened] | ||
|
|
||
| jobs: | ||
| # The `if:` condition checks an actor field that is populated for | ||
| # `pull_request_target` events, so the injectable step is protected. | ||
| valid-actor-check: | ||
| runs-on: ubuntu-latest | ||
| if: github.event.pull_request.user.login == 'trusted-user' | ||
| steps: | ||
| - run: echo '${{ github.event.pull_request.title }}' |
46 changes: 46 additions & 0 deletions
46
actions/ql/test/query-tests/Security/CWE-094/.github/workflows/actor_check_wrong_event.yml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| on: | ||
| issues: | ||
| types: [opened] | ||
|
|
||
| jobs: | ||
| # The `if:` condition compares an actor field that is never populated for | ||
| # `issues` events, so it is always true and does not protect the injectable step. | ||
| vacuous-actor-check: | ||
| runs-on: ubuntu-latest | ||
| if: github.event.pull_request.user.login != 'some-bot[bot]' | ||
| steps: | ||
| - run: echo '${{ github.event.issue.title }}' | ||
|
|
||
| # The `if:` condition checks an actor context that is populated for every | ||
| # event, so the injectable step is protected. | ||
| valid-actor-check: | ||
| runs-on: ubuntu-latest | ||
| if: github.actor == 'trusted-user' | ||
| steps: | ||
| - run: echo '${{ github.event.issue.title }}' | ||
|
|
||
| # The `sender` object is part of every webhook event payload, so this | ||
| # check is effective and the injectable step is protected. | ||
| valid-sender-check: | ||
| runs-on: ubuntu-latest | ||
| if: github.event.sender.login == 'trusted-user' | ||
| steps: | ||
| - run: echo '${{ github.event.issue.title }}' | ||
|
|
||
| # `github.event.head_commit` is only populated for `push` events, so this | ||
| # condition is always true for `issues` events and does not protect the | ||
| # injectable step. | ||
| vacuous-head-commit-check: | ||
| runs-on: ubuntu-latest | ||
| if: github.event.head_commit.author.name != 'some-bot' | ||
| steps: | ||
| - run: echo '${{ github.event.issue.title }}' | ||
|
|
||
| # `github.event.commits` is only populated for `push` events, so this | ||
| # condition is always true for `issues` events and does not protect the | ||
| # injectable step. | ||
| vacuous-commits-check: | ||
| runs-on: ubuntu-latest | ||
| if: github.event.commits[0].author.name != 'some-bot' | ||
| steps: | ||
| - run: echo '${{ github.event.issue.title }}' |
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.