Skip to content

fix: mitigate GITHUB_ENV injection in workflow_run workflow - #2113

Merged
svor merged 1 commit into
mainfrom
fix/workflow-env-injection-cve
Aug 14, 2026
Merged

fix: mitigate GITHUB_ENV injection in workflow_run workflow#2113
svor merged 1 commit into
mainfrom
fix/workflow-env-injection-cve

Conversation

@svor

@svor svor commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

The publish-pr-check-content workflow reads PR_SHA from an attacker-controlled artifact and writes it to $GITHUB_ENV without validation, allowing fork PR authors to inject arbitrary environment variables (BASH_ENV, PATH, LD_PRELOAD) and achieve code execution with access to SURGE_TOKEN and the write-scoped GITHUB_TOKEN.

Mitigations applied:

  • Replace artifact-sourced PR_SHA with github.event.workflow_run.head_sha
  • Add ^[0-9a-f]{40}$ validation on the SHA (defense-in-depth)
  • Add explicit permissions: statuses: write to restrict GITHUB_TOKEN scope
  • Fix unquoted shell variables in find loops (prevents word-splitting attacks)
  • Remove the now-unused pull-request-sha artifact from the producer workflow

What does this PR do?

Screenshot/screencast of this PR

What issues does this PR fix or reference?

How to test this PR?

Release Notes

PR Checklist

As the author of this Pull Request I made sure that:

Reviewers

Reviewers, please comment how you tested the PR when approving it.

The publish-pr-check-content workflow reads PR_SHA from an
attacker-controlled artifact and writes it to $GITHUB_ENV without
validation, allowing fork PR authors to inject arbitrary environment
variables (BASH_ENV, PATH, LD_PRELOAD) and achieve code execution
with access to SURGE_TOKEN and the write-scoped GITHUB_TOKEN.

Mitigations applied:
- Replace artifact-sourced PR_SHA with github.event.workflow_run.head_sha
- Add ^[0-9a-f]{40}$ validation on the SHA (defense-in-depth)
- Add explicit permissions: statuses: write to restrict GITHUB_TOKEN scope
- Fix unquoted shell variables in find loops (prevents word-splitting attacks)
- Remove the now-unused pull-request-sha artifact from the producer workflow

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Valerii Svydenko <vsvydenk@redhat.com>
@svor
svor requested review from ibuziuk and vinokurig as code owners August 14, 2026 13:02
@openshift-ci

openshift-ci Bot commented Aug 14, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: svor

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@github-actions

Copy link
Copy Markdown

Click here to review and test in web IDE: Contribute

@svor
svor merged commit a7e2b6b into main Aug 14, 2026
15 of 18 checks passed
@svor
svor deleted the fix/workflow-env-injection-cve branch August 14, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant