Skip to content
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

github: prevent script injections via PR branch names #1083

Merged
merged 1 commit into from
Dec 3, 2024

Conversation

ondrejbudai
Copy link
Member

@ondrejbudai ondrejbudai commented Dec 2, 2024

Prior this commit, ${{ github.event.workflow_run.head_branch }} got expanded in the bash script. A malicious actor could inject an arbitrary shell script. Since this action has access to a token with write rights the malicious actor can easily steal this token.

This commit moves the expansion into an env block where such an injection cannot happen. This is the preferred way according to the github docs:
https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable

Note that we don't allow external contributors to run CI without our manual approval, so this could not actually be abused.

Prior this commit, ${{ github.event.workflow_run.head_branch }} got
expanded in the bash script. A malicious actor could inject
an arbitrary shell script. Since this action has access to a token
with write rights the malicious actor can easily steal this token.

This commit moves the expansion into an env block where such an
injection cannot happen. This is the preferred way according to the
github docs:
https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
Copy link
Member

@achilleas-k achilleas-k left a comment

Choose a reason for hiding this comment

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

I see!

@achilleas-k achilleas-k enabled auto-merge December 2, 2024 15:11
@achilleas-k
Copy link
Member

Note that we don't allow external contributors to run CI without our manual approval, so this could not actually be abused.

True, but I'll admit I never pay too much attention to the BRANCH NAME before approving a run.

@achilleas-k achilleas-k added this pull request to the merge queue Dec 3, 2024
Merged via the queue into osbuild:main with commit fcf4d68 Dec 3, 2024
19 checks passed
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.

4 participants