fix(workflows): Prevent shell injection in fast-revert workflow#556
Merged
fix(workflows): Prevent shell injection in fast-revert workflow#556
Conversation
Use environment variables instead of direct GitHub context interpolation in run steps to prevent potential shell injection attacks. Fixes VULN-1096 Fixes STREAM-694 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Comment on lines
49
to
54
| --silent \ | ||
| -X POST \ | ||
| -H 'Authorization: token ${{ steps.token.outputs.token }}' \ | ||
| -d'{"body": "revert failed (conflict? already reverted?) -- [check the logs](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})"}' \ | ||
| https://api.github.com/repositories/${{ github.event.repository.id }}/issues/${{ github.event.number || github.event.inputs.pr }}/comments | ||
| -H "Authorization: token $GH_TOKEN" \ | ||
| -d"{\"body\": \"revert failed (conflict? already reverted?) -- [check the logs](https://github.com/$GH_REPOSITORY/actions/runs/$GH_RUN_ID)\"}" \ | ||
| "https://api.github.com/repositories/$GH_REPO_ID/issues/$PR_NUMBER/comments" | ||
| if: failure() |
There was a problem hiding this comment.
Bug: When triggered via workflow_dispatch, the GH_REPO_ID variable is empty, causing the failure notification step to silently fail due to a malformed API URL.
Severity: MEDIUM
Suggested Fix
Ensure the repository ID is correctly sourced for all trigger types. Instead of relying on github.event.repository.id, which is not present in workflow_dispatch events, use the universally available github.repository_id context variable to populate GH_REPO_ID.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: .github/workflows/fast-revert.yml#L49-L54
Potential issue: When the workflow is triggered via `workflow_dispatch`, the
`github.event.repository.id` context variable is unavailable. This results in the
`GH_REPO_ID` environment variable being set to an empty string. Consequently, the
'comment on failure' step constructs a malformed API URL
(`https://api.github.com/repositories//issues/...`) for its `curl` command. This causes
the API call to fail, silently preventing a failure notification comment from being
posted to the pull request if the main revert action fails. This issue only occurs with
the `workflow_dispatch` trigger.
Did we get this right? 👍 / 👎 to inform future reviews.
markstory
approved these changes
Feb 19, 2026
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.
Summary
This PR fixes a security finding by preventing potential shell injection in the fast-revert GitHub Actions workflow.
Changes
.github/workflows/fast-revert.ymlto use environment variables instead of direct GitHub context interpolation inrun:stepsenv:section and referenced as environment variables in the shell scriptSecurity Details
The original code used direct interpolation of GitHub context variables (
${{ ... }}) in shell commands, which could potentially allow code injection attacks. While the specific variables used (repository ID, run ID, etc.) are likely safe, following security best practices requires using intermediate environment variables.Before:
After:
References
Testing