Skip to content

Actions: ActorIfCheck ControlCheck model fix for events that don't populate the checked field - #22368

Open
computersarebad wants to merge 1 commit into
github:mainfrom
computersarebad:actor-if-check-event-validity
Open

Actions: ActorIfCheck ControlCheck model fix for events that don't populate the checked field#22368
computersarebad wants to merge 1 commit into
github:mainfrom
computersarebad:actor-if-check-event-validity

Conversation

@computersarebad

@computersarebad computersarebad commented Aug 17, 2026

Copy link
Copy Markdown

Fixes #22367

Currently ActorIfCheck treats a condition as an actor check if it mentions a field like github.event.pull_request.user.login anywhere in the if: expression, and the check then counts as protection for all the events ActorCheck covers. It never looks at whether that field is even populated for the event triggering the workflow. On an issues event github.event.pull_request is null, so something like if: github.event.pull_request.user.login != 'some-bot[bot]' is always true and gates nothing, but it still suppressed actions/code-injection/critical (repro in the linked issue).

This change overrides protectsCategoryAndEvent in ActorIfCheck so payload field checks only protect events whose payload actually contains that context, reusing the existing contextTriggerDataModel extension for the mapping. Checks on github.actor, github.triggering_actor and github.event.sender.login still protect every event since those are always populated. The characteristic predicate is unchanged, including the %[bot]% exclusion.

This is the same kind of fix as #22154 did for EnvironmentCheck, which suggested reviewing if other check types have this issue. Added two testcases: actor_check_wrong_event.yml with the vacuous check (now detected as critical) next to a valid github.actor check (still medium), and actor_check_valid_event.yml with a github.event.pull_request.user.login check on a pull_request_target event, which is populated there and still suppresses the critical alert. No existing test results change.

…the checked field

A condition like 'github.event.pull_request.user.login != ...' on a
workflow triggered by issues events is always true since
github.event.pull_request is not populated for issues events, but
ActorIfCheck still treated it as a protective check, suppressing
alerts such as actions/code-injection/critical.

Override protectsCategoryAndEvent in ActorIfCheck so that checks on
event payload fields only protect events whose payload contains the
corresponding context, using contextTriggerDataModel as the mapping.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4084febb-f9c7-44df-baf3-c8be8e9932a7
@github-actions github-actions Bot added documentation Actions Analysis of GitHub Actions labels Aug 17, 2026
@computersarebad
computersarebad marked this pull request as ready for review August 18, 2026 00:00
@computersarebad
computersarebad requested a review from a team as a code owner August 18, 2026 00:00
Copilot AI balanced review requested due to automatic review settings August 18, 2026 00:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates ActorIfCheck to consider whether event payload actor fields exist for the triggering event.

Changes:

  • Maps payload actor checks to compatible events.
  • Adds valid and vacuous actor-check fixtures.
  • Updates expected query results and release notes.
Show a summary per file
File Description
ControlChecks.qll Adds event-aware actor-check protection logic.
actor_check_wrong_event.yml Tests a vacuous payload check and valid global actor check.
actor_check_valid_event.yml Tests a valid pull-request payload check.
CodeInjectionMedium.expected Updates generated medium-query results.
CodeInjectionCritical.expected Updates generated critical-query results.
2026-08-17-actor-if-check-event-validity.md Documents the analysis change.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 6/6 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread actions/ql/lib/codeql/actions/security/ControlChecks.qll
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Actions Analysis of GitHub Actions documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Actions: vacuous if: condition suppresses code-injection alert

2 participants