fix Expression injection in Actions#23358
Merged
diox merged 1 commit intomozilla:masterfrom Apr 24, 2025
odaysec:patch-1
Merged
fix Expression injection in Actions#23358diox merged 1 commit intomozilla:masterfrom odaysec:patch-1
diox merged 1 commit intomozilla:masterfrom
odaysec:patch-1
Conversation
Member
|
Thanks for the pull request, that looks good. We have more planned in mozilla/addons#15312 but it's a good first step. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
addons-server/.github/actions/context/action.yml
Lines 69 to 129 in c9a6ce1
fix the issue will follow the recommended best practice of assigning the untrusted input (
${{ github.head_ref }}) to an environment variable and referencing it using shell syntax ($VAR). This approach ensures that the input is treated as a literal string by the shell, mitigating the risk of command injection.Specifically:
${{ github.head_ref }}in the script with an environment variable (e.g.,HEAD_REF).$HEAD_REFin the script.Using user-controlled input in GitHub Actions may lead to code injection in contexts like run: or script:. Code injection in GitHub Actions may allow an attacker to exfiltrate any secrets used in the workflow and the temporary GitHub repository authorization token. The token might have write access to the repository, allowing an attacker to use the token to make changes to the repository.
The following lets a user inject an arbitrary shell command:
The following uses an environment variable, but still allows the injection because of the use of expression syntax:
The following uses shell syntax to read the environment variable and will prevent the attack:
References
Keeping your GitHub Actions and workflows secure: Untrusted input
Security hardening for GitHub Actions
Permissions for the GITHUB_TOKEN
CWE-94
#ISSUENUMat the top of your PR to an existing open issue in the mozilla/addons repository.