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
24 changes: 24 additions & 0 deletions .github/workflows/pr-label-context.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: PR label context

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

permissions:
issues: write
pull-requests: write

jobs:
label-context:
runs-on: ubuntu-latest
steps:
- name: Publish label context
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
with:
script: |
const title = '${{ github.event.pull_request.title }}';

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: Untrusted pull request titles can inject JavaScript into a privileged pull_request_target job

PR title is spliced into privileged github-script JavaScript, allowing title-controlled code execution.

Read the title from context.payload or process.env; never interpolate it into executable script source.

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-label-context.yml">
<violation number="1" location=".github/workflows/pr-label-context.yml:19">
<priority>P0</priority>
<title>Untrusted pull request titles can inject JavaScript into a privileged pull_request_target job</title>
<evidence>The workflow is triggered by pull_request_target at lines 3-5 and grants issues: write and pull-requests: write at lines 7-9. At line 19, the attacker-controlled github.event.pull_request.title is inserted directly between JavaScript string delimiters: const title = '${{ github.event.pull_request.title }}';. actions/github-script executes the resulting script, so a title containing JavaScript string-breaking syntax can alter the program and execute attacker-chosen JavaScript in the privileged runner context. The base revision has no pr-label-context.yml workflow; its existing welcome-pr workflow reads pull request metadata from context.payload inside the script rather than interpolating the title into executable source, so this is a newly introduced code-execution path.</evidence>
<recommendation>Do not interpolate pull request metadata into the github-script source. Pass the value through the action's environment and read it from process.env, or use the already available context.payload.pull_request.title inside the script. Keep the job least-privileged and avoid pull_request_target if write access is not required.</recommendation>
</violation>
</file>

await github.rest.issues.createComment({
...context.repo,
issue_number: context.issue.number,
body: `Review context: ${title}`,
});
Loading