-
-
Notifications
You must be signed in to change notification settings - Fork 2k
fix(workflows): Prevent shell injection in fast-revert workflow #4309
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,11 +30,17 @@ jobs: | |
| committer_email: bot@sentry.io | ||
| token: ${{ secrets.BUMP_SENTRY_TOKEN }} | ||
| - name: comment on failure | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.BUMP_SENTRY_TOKEN }} | ||
| GITHUB_REPOSITORY: ${{ github.repository }} | ||
| GITHUB_RUN_ID: ${{ github.run_id }} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reserved env var names override silently ignoredLow Severity
Reviewed by Cursor Bugbot for commit 7c6ae0e. Configure here. |
||
| REPOSITORY_ID: ${{ github.event.repository.id }} | ||
| PR_NUMBER: ${{ github.event.number || github.event.inputs.pr }} | ||
| run: | | ||
| curl \ | ||
| --silent \ | ||
| -X POST \ | ||
| -H 'Authorization: token ${{ secrets.BUMP_SENTRY_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 $GITHUB_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/$REPOSITORY_ID/issues/$PR_NUMBER/comments" | ||
| if: failure() | ||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: The workflow attempts to overwrite the reserved
GITHUB_TOKENenvironment variable. This is ignored, and the subsequent API call will use a token with no permissions, causing it to fail.Severity: MEDIUM
Suggested Fix
Instead of trying to overwrite
GITHUB_TOKEN, use a different environment variable name for your PAT, for example,GH_TOKEN. Then, update thecurlcommand to use this new variable:Authorization: Bearer ${{ env.GH_TOKEN }}.Prompt for AI Agent
Did we get this right? 👍 / 👎 to inform future reviews.