Commit ccd344f
authored
fix(ci): avoid branch-name command injection in image dispatch (#8513)
### Motivation
- Prevent command injection and secret exfiltration risk when a labeled
PR triggers the image-dispatch path by ensuring untrusted branch names
are not interpolated directly into shell script bodies.
### Description
- In the Azure Pipelines job, read the PR source branch from an
environment variable `PR_SOURCE_BRANCH` instead of embedding
`$(System.PullRequest.SourceBranch)` directly into the script, and
normalize it by stripping the `refs/heads/` prefix with
`BRANCH_NAME="${BRANCH_NAME#refs/heads/}"` before use.
- Quote the `REF` assignment (`REF="$(Build.SourceBranch)"`) to avoid
accidental word-splitting during parsing.
- Expose `PR_SOURCE_BRANCH` via the job `env` so the pipeline consumes
an env var rather than untrusted inline interpolation.
- In the dispatched GitHub Actions workflow, stop embedding `�${{
github.event.inputs.branch_name }}` directly in the script and instead
pass the input through a step `env` variable `BRANCH_NAME_INPUT` and
then sanitize/normalize that variable in-shell before generating the
`image_tag`.
### Testing
- No automated tests were run for this change.
------
[Codex
Task](https://chatgpt.com/codex/cloud/tasks/task_b_69e94906c8248327bc2843e43daeaef7)1 parent a5f6d3d commit ccd344f
2 files changed
Lines changed: 7 additions & 3 deletions
File tree
- .azure-pipelines
- .github/workflows
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4320 | 4320 | | |
4321 | 4321 | | |
4322 | 4322 | | |
4323 | | - | |
| 4323 | + | |
4324 | 4324 | | |
4325 | 4325 | | |
4326 | 4326 | | |
| |||
4329 | 4329 | | |
4330 | 4330 | | |
4331 | 4331 | | |
4332 | | - | |
| 4332 | + | |
| 4333 | + | |
4333 | 4334 | | |
4334 | 4335 | | |
4335 | 4336 | | |
| |||
4358 | 4359 | | |
4359 | 4360 | | |
4360 | 4361 | | |
| 4362 | + | |
4361 | 4363 | | |
4362 | 4364 | | |
4363 | 4365 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
| 63 | + | |
62 | 64 | | |
63 | 65 | | |
64 | 66 | | |
| |||
0 commit comments