Commit 92ea305
authored
ci: fix shell injection via github.head_ref in auto-fixer (#2558)
## Bug
\`pr-no-generated-changes.yml\` interpolated \`github.head_ref\` (the PR
branch name, attacker-controlled) directly into a shell command:
\`\`\`yaml
git push origin HEAD:\${{ github.head_ref }}
\`\`\`
A PR opened with a branch name like \`;rm -rf /;\` (or anything
containing shell metacharacters) would execute arbitrary commands inside
the auto-fixer job. That job runs with the \`AUTOFIXER_APP_SECRET\`
GitHub App credentials, which have write access to the repo — so this is
a real privilege-escalation vector for any external contributor opening
a PR.
## Fix
Route \`github.head_ref\` and \`inputs.commit\` through env vars so the
values are quoted shell data instead of inlined source:
\`\`\`yaml
env:
HEAD_REF: \${{ github.head_ref }}
COMMIT: \${{ inputs.commit }}
run: |
...
git push origin "HEAD:\$HEAD_REF"
\`\`\`
Standard mitigation per [GitHub's secure-use
guide](https://docs.github.com/en/actions/reference/security/secure-use#good-practices-for-mitigating-script-injection-attacks).
## Diff
1 file, +8/−3.1 parent 69250d8 commit 92ea305
1 file changed
Lines changed: 8 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
79 | 84 | | |
80 | 85 | | |
81 | 86 | | |
82 | 87 | | |
83 | 88 | | |
84 | 89 | | |
85 | | - | |
| 90 | + | |
86 | 91 | | |
87 | 92 | | |
88 | 93 | | |
89 | 94 | | |
90 | | - | |
| 95 | + | |
91 | 96 | | |
92 | 97 | | |
93 | 98 | | |
| |||
96 | 101 | | |
97 | 102 | | |
98 | 103 | | |
99 | | - | |
| 104 | + | |
100 | 105 | | |
101 | 106 | | |
102 | 107 | | |
| |||
0 commit comments