-
Notifications
You must be signed in to change notification settings - Fork 33
fix shell/code injection in pr-review.yaml #296
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
fix shell/code injection in pr-review.yaml #296
Conversation
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.
Pull request overview
This pull request fixes a code injection vulnerability in the GitHub Actions workflow file .github/workflows/PR-review.yaml by properly handling untrusted user inputs. The workflow is triggered by issue comments and previously used direct template expansion of user-controlled values (like github.event.comment.body and github.event.issue.number) within shell run: blocks, which could allow malicious users to inject arbitrary shell commands.
Changes:
- Modified the "PR Info" step to assign untrusted GitHub event inputs to environment variables before using them in shell commands
- Modified the "Get PR Details" step to use environment variables for API calls instead of direct template expansion
- Removed trailing whitespace in the workflow file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #Assign untrusted inputs to environment variables first | ||
| COMMENT_BODY: ${{ github.event.comment.body }} | ||
| ISSUE_NUM: ${{ github.event.issue.number }} | ||
| REPO: ${{ github.repository }} | ||
| #Use shell variables ("$VAR") instead of template tags |
Copilot
AI
Feb 12, 2026
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.
The comment placement here is confusing. Line 21's comment appears between the env: key and its values, making the structure unclear. Consider either: (1) indenting it to align with the environment variables (e.g., " #Assign..."), (2) placing it on the same line as env: (e.g., "env: #Assign..."), or (3) moving it above the env: line. Similarly, line 25's comment should be moved inside the run block or placed differently to improve readability.
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| REPO: ${{ github.repository }} | ||
| ISSUE_NUM: ${{ github.event.issue.number }} | ||
| #Use env vars for the API call to prevent injection | ||
| #Use quotes around variables to prevent word splitting | ||
| run: | |
Copilot
AI
Feb 12, 2026
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.
The comment placement here is confusing. Lines 43-44 appear at the wrong indentation level, between the environment variable definitions and the run: key. Consider indenting these comments to align with the environment variables (e.g., " #Use env vars...") to improve readability and make the YAML structure clearer.
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| REPO: ${{ github.repository }} | |
| ISSUE_NUM: ${{ github.event.issue.number }} | |
| #Use env vars for the API call to prevent injection | |
| #Use quotes around variables to prevent word splitting | |
| run: | | |
| # Use env vars for the API call to prevent injection | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| REPO: ${{ github.repository }} | |
| ISSUE_NUM: ${{ github.event.issue.number }} | |
| run: | | |
| # Use quotes around variables to prevent word splitting |
@pradeeban, done with the changes, please have a look. This fixes #295