-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Resolve template injection on comment command #7546
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 | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -18,4 +18,6 @@ | |||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||
| # Using REST API and not `gh issue edit`. https://github.com/cli/cli/issues/6235#issuecomment-1243487651 | ||||||||||||||||||||||||
| - run: | | ||||||||||||||||||||||||
| curl -H "Authorization: token ${{ github.token }}" -d '{"assignees": ["${{ github.event.comment.user.login }}"]}' https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/assignees | ||||||||||||||||||||||||
| curl -H "Authorization: token ${{ github.token }}" -d '{"assignees": ["${{ env.USER }}"]}' https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/assignees | ||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||
| USER: ${{ github.event.comment.user.login }} | ||||||||||||||||||||||||
|
Comment on lines
+21
to
+23
Contributor
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. 🧩 Analysis chain🌐 Web query: `For GitHub Actions security hardening:
💡 Result:
Sources Use runtime JSON encoding instead of expression interpolation in payload. At line 21, Suggested hardening- - run: |
- curl -H "Authorization: token ${{ github.token }}" -d '{"assignees": ["${{ env.USER }}"]}' https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/assignees
+ - run: |
+ payload="$(jq -cn --arg user "$USER" '{assignees: [$user]}')"
+ curl -fsS \
+ -H "Authorization: token ${{ github.token }}" \
+ -H "Content-Type: application/json" \
+ -d "$payload" \
+ "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/assignees"
env:
USER: ${{ github.event.comment.user.login }}This uses shell variable substitution ( 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
Check notice
Code scanning / zizmor
code injection via template expansion Note