Skip to content

Actions: only count association checks for events that populate the checked field - #22391

Merged
jketema merged 1 commit into
github:mainfrom
computersarebad:association-check-event-validity
Aug 20, 2026
Merged

Actions: only count association checks for events that populate the checked field#22391
jketema merged 1 commit into
github:mainfrom
computersarebad:association-check-event-validity

Conversation

@computersarebad

Copy link
Copy Markdown
Contributor

Fixes #22388

A workflow gated by if: github.event.pull_request.author_association != 'NONE' but triggered by issues or issue_comment isn't actually protected, since those payloads don't have a top-level pull_request and the condition is always true for them. Anyone who opens an issue or comments reaches the job. AssociationIfCheck still counted that gate as protection and suppressed alerts on these workflows, which is the same false negative that #22368 fixed for actor checks. This PR applies the same fix to association checks, using the contextTriggerDataModel mapping to decide which events actually populate the field a check reads, so a check only counts as protection for those events.

Some existing test results move around as a result. A few of the untrusted-checkout testcases happen to use this exact vacuous gate on issue_comment workflows, so their alerts move from the TOCTOU queries over to actions/untrusted-checkout/critical. I think that's the right outcome, since a gate that never gates isn't something you can win a race against, and the TOCTOU suggestion of pinning the reviewed SHA wouldn't have helped those workflows. The testcases that use valid comment. and issue.author_association gates are unchanged, and I've added new ones covering a vacuous check next to a valid one.

…ulate the checked field

Same problem as EventActorIfCheck had. A condition like
'github.event.pull_request.author_association != NONE' on a workflow
triggered by issues events is always true since
github.event.pull_request is not populated there, but it still counted
as a protective check for those events.

Bind the matched context prefix in the characteristic predicate and
require contextTriggerDataModel to populate it for the event, following
the pattern from github#22368. Existing TOCTOU alerts on vacuous gates
migrate to the untrusted-checkout critical query, since a vacuous gate
is no protection rather than raceable protection.

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

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 association-based control checks to ignore event payload fields unavailable for the triggering event.

Changes:

  • Maps association checks to compatible event payload contexts.
  • Adds valid and vacuous association-check test cases.
  • Updates affected query expectations and release notes.
Show a summary per file
File Description
ControlChecks.qll Adds event-aware association checks.
association_check_wrong_event.yml Tests valid and vacuous gates.
CodeInjectionCritical.expected Updates critical-alert expectations.
CodeInjectionMedium.expected Updates medium-alert expectations.
UntrustedCheckoutCritical.expected Records newly detected critical alerts.
UntrustedCheckoutTOCTOUCritical.expected Removes reclassified TOCTOU alerts.
UntrustedCheckoutTOCTOUHigh.expected Removes reclassified high alerts.
2026-08-19-association-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: 8/8 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread actions/ql/lib/codeql/actions/security/ControlChecks.qll

@jketema jketema 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.

LGTM.

@jketema
jketema merged commit 3290afc into github:main Aug 20, 2026
18 checks passed
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 author_association check also suppresses code-injection alerts

3 participants