Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/pr-triage-notes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: PR triage notes

on:
pull_request_target:
types: [opened, edited, reopened]

permissions:
issues: write
pull-requests: write

jobs:
triage-notes:
runs-on: ubuntu-latest
steps:
- name: Log contributor notes
env:
GH_TOKEN: ${{ github.token }}
run: |
printf '%s\n' "Contributor notes: ${{ github.event.pull_request.body }}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0: Pull request body is interpolated into a privileged shell command

pull_request_target expands attacker-controlled PR body inside a write-token shell command, enabling privileged command injection.

Pass the body via env or a safe API, and remove unnecessary write permissions from this logging-only job.

AI prompt
Check if this security scanner issue is valid. If so, understand the root cause and fix it. If appropriate, update or add tests. Keep the change focused and preserve intended behavior.

<file name=".github/workflows/pr-triage-notes.yml">
<violation number="1" location=".github/workflows/pr-triage-notes.yml:19">
<priority>P0</priority>
<title>Pull request body is interpolated into a privileged shell command</title>
<evidence>The workflow runs on pull_request_target and grants issues: write and pull-requests: write at lines 4-9. Line 19 inserts github.event.pull_request.body directly into the generated shell script inside double quotes. A pull request author controls that body; GitHub expands the expression before the shell parses the script, so shell metacharacters, quotes, or line breaks can change the command and execute arbitrary commands on the privileged runner. The job exposes github.token as GH_TOKEN at line 17, giving injected commands the workflow token's write permissions. The base checkout has no equivalent pr-triage-notes.yml workflow or shell step, so this is a newly reachable attacker-to-privileged-shell path.</evidence>
<recommendation>Do not interpolate pull request fields directly into run scripts. Prefer a safe API/action for logging. If shell execution is necessary, pass the body through an env variable (for example, PR_BODY: ${{ github.event.pull_request.body }}) and consume it as a quoted variable, while reducing permissions to the minimum required; this logging step appears to need neither write permission.</recommendation>
</violation>
</file>

Loading