fix: prevent shell injection vulnerabilities (SEC-4316)#76
Merged
Conversation
Comment on lines
86
to
100
| run: | | ||
| # Use poetry to bump the version in pyproject.toml | ||
| poetry version "${{ steps.version.outputs.new_release_version }}" | ||
| poetry version "$NEW_RELEASE_VERSION" | ||
|
|
||
| # Specify the user name and email which is required to commit with a token auth | ||
| git config user.email "${{ inputs.git-user-name }}" | ||
| git config user.name "${{ inputs.git-user-email }}" | ||
| git config user.email "$GIT_USER_NAME" | ||
| git config user.name "$GIT_USER_EMAIL" | ||
|
|
||
| # Commit the bumped project version with a non-semver chore: commit message | ||
| git add pyproject.toml | ||
| git --no-pager diff --staged | ||
| git commit --author="${{ inputs.git-user-name }} <${{ inputs.git-user-email }}>" -m "chore: release ${{ steps.version.outputs.new_release_version }}" -m "[skip actions]" | ||
| git commit --author="$GIT_USER_NAME <$GIT_USER_EMAIL>" -m "chore: release $NEW_RELEASE_VERSION" -m "[skip actions]" | ||
|
|
||
| # Push the changes to the current (should be main) branch, if this is not a dry-run | ||
| # TODO: This might not be super safe, we should consider that this could |
There was a problem hiding this comment.
Using variable interpolation ${{...}} with github context data in a run: step could allow an attacker to inject their own code into the runner. This would allow them to steal secrets and code. github context data can have arbitrary user input and should be treated as untrusted. Instead, use an intermediate environment variable with env: to store the data and use the environment variable in the run: script. Be sure to use double-quotes the environment variable, like this: "$ENVVAR".
🍰 Fixed in commit d1c28c8 🍰
- Add env var for inputs.dry-run - Fix lines 104 and 109 with proper env variable usage - Semgrep findings: yaml.github-actions.security.run-shell-injection Jira: SEC-4316
bilals12
approved these changes
Oct 21, 2025
|
🎉 This PR is included in version 2.4.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
🔒 Security Fix: Shell Injection Prevention
Issue
Fixes shell injection vulnerability identified in Jira ticket SEC-4316.
Semgrep Finding:
yaml.github-actions.security.run-shell-injection.run-shell-injectionAffected Files:
release-poetry-package/action.yaml(lines 82-93, 104, 109)What Changed
Modified GitHub Actions workflow file to prevent shell injection by using intermediate environment variables instead of direct interpolation of GitHub expressions in shell scripts.
Initial Fix:
NEW_RELEASE_VERSION,GIT_USER_NAME,GIT_USER_EMAILAdditional Fix (after Semgrep scan):
${{ inputs.dry-run }}→ env varDRY_RUN${{ steps.version.outputs.new_release_version }}→ use existing env varNEW_RELEASE_VERSIONPattern Applied:
run: | poetry version "${{ steps.version.outputs.new_release_version }}"Security Context
Direct interpolation of GitHub expressions (
${{ ... }}) in shell scripts can lead to command injection if the input contains shell metacharacters. By using environment variables as intermediaries, we ensure inputs are treated as data rather than executable code.Reference: GitHub Actions Security Hardening
Testing
Review Checklist