fix(actions): prevent command injection in GHA workflow (WPB-9709) #27
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.
PR Submission Checklist for internal contributors
The PR Title
SQPIT-764
The PR Description
What's new in this PR?
Issues
This PR fixes a potential command injection in the GitHub Actions workflow of this repository.
A user input (in this case a git tag) was used in a run step without sanitization.
Because of this, a specially crafted tag, e.g.
docker/v0.0.0;$(cat${IFS}/etc/passwd)#
, could be used to execute arbitrary code in the context of the workflow.Solutions
Instead of using the unsanitized tag directly, it is passed to the run step as an environment variable. This prevents command execution like in the above example.
Testing
How to Test
This change was tested with the workflow listed below in a separate repository by pushing tags in the shape of
'docker/v0.0.0;$(cat${IFS}/etc/passwd)#'
.Test0
resembles the original workflow of this repo, andTest1
is the fixed version.An actual test can be made by pushing above tag to a repo with below workflow:
Notes
Exploiting this requires knowledge of the workflow code, execution environment and, most importantly, tag push permission.
Note that git tags are quite restrictive in terms of which characters are allowed, so one cannot just paste a shell script, and that the tag push permission would usually imply that an attacker would already be able to directly modify workflow code.
Nevertheless, as a best practice, we shall try to sanitize any user input that is used in a run step.
PR Post Submission Checklist for internal contributors
PR Post Merge Checklist for internal contributors
References
feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764
.