Is there an existing issue for this?
Does this issue exist in the latest version?
Describe the bug?
Potential README update? Issue might in the consumer shell step, not in tj-actions/changed-files itself, but I don't see any mapfile or similar use recommendation in README.
Claimed vulnerable usage pattern ⬇️
run: npx prettier --check ${{ steps.changed-files.outputs.all_changed_files }}
If a PR includes a file whose name itself looks like a CLI flag, GitHub expands that output directly into the shell command line.
Example:
- attacker adds a file named
--config=pwn.cjs
- attacker also adds
pwn.cjs
Generated shell command becomes:
npx prettier --check --config=pwn.cjs pwn.cjs
At that point Prettier does not see --config=pwn.cjs as a filename — it sees it as an option. Since Prettier can load JS config/plugin files, that can turn attacker-controlled repo content into code execution in CI.
Recommendation is to make boundaries explicit:
- read the changed files as JSON
- parse them into a bash array
- invoke Prettier as: `npx prettier --check -- "${files[@]}"
Proposed solution template:
...
jobs:
prettier:
runs-on: ubuntu-slim
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/restore-node-modules-cache
- id: changed-files
uses: tj-actions/changed-files@v47
with:
json: true
escape_json: false
- if: steps.changed-files.outputs.any_changed == 'true'
env:
CHANGED_FILES_JSON: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
mapfile -t files < <(printf '%s' "$CHANGED_FILES_JSON" | jq -r '.[]')
npx prettier --check -- "${files[@]}"
Is this a real problem? Should https://github.com/tj-actions/changed-files/blob/v47/README.md be upgraded?
To Reproduce
Follow https://github.com/tj-actions/changed-files/blob/v47/README.md as-is.
What OS are you seeing the problem on?
all
Expected behavior?
Perhaps README.md should harden its recommendations?
Relevant log output
Has all relevant logs been included?
Anything else?
No response
Code of Conduct
Is there an existing issue for this?
Does this issue exist in the latest version?
Describe the bug?
Potential README update? Issue might in the consumer shell step, not in tj-actions/changed-files itself, but I don't see any
mapfileor similar use recommendation in README.Claimed vulnerable usage pattern ⬇️
If a PR includes a file whose name itself looks like a CLI flag, GitHub expands that output directly into the shell command line.
Example:
--config=pwn.cjspwn.cjsGenerated shell command becomes:
At that point Prettier does not see
--config=pwn.cjsas a filename — it sees it as an option. Since Prettier can load JS config/plugin files, that can turn attacker-controlled repo content into code execution in CI.Recommendation is to make boundaries explicit:
Proposed solution template:
Is this a real problem? Should https://github.com/tj-actions/changed-files/blob/v47/README.md be upgraded?
To Reproduce
Follow https://github.com/tj-actions/changed-files/blob/v47/README.md as-is.
What OS are you seeing the problem on?
all
Expected behavior?
Perhaps README.md should harden its recommendations?
Relevant log output
Has all relevant logs been included?
Anything else?
No response
Code of Conduct