{"id":"GHSA-mcph-m25j-8j63","summary":"tj-actions/changed-files has Potential Actions command injection in output filenames (GHSL-2023-271)","details":"### Summary\nThe `tj-actions/changed-files` workflow allows for command injection in changed filenames, allowing an attacker to execute arbitrary code and potentially leak secrets.\n\n### Details\nThe [`changed-files`](https://github.com/tj-actions/changed-files) action returns a list of files changed in a commit or pull request which provides an `escape_json` input [enabled by default](https://github.com/tj-actions/changed-files/blob/94549999469dbfa032becf298d95c87a14c34394/action.yml#L136), only escapes `\"` for JSON values. \n\nThis could potentially allow filenames that contain special characters such as `;` and \\` (backtick) which can be used by an attacker to take over the [GitHub Runner](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners) if the output value is used in a raw fashion (thus being directly replaced before execution) inside a `run` block. By running custom commands an attacker may be able to steal **secrets** such as `GITHUB_TOKEN` if triggered on other events than `pull_request`. For example on `push`.\n\n#### Proof of Concept\n\n1. Submit a pull request to a repository with a new file injecting a command. For example `$(whoami).txt` which is a valid filename.\n2. Upon approval of the workflow (triggered by the pull request), the action will get executed and the malicious pull request filename will flow into the `List all changed files` step below.\n\n```yaml\n      - name: List all changed files\n        run: |\n          for file in ${{ steps.changed-files.outputs.all_changed_files }}; do\n            echo \"$file was changed\"\n          done\n```\n\nExample output:\n\n```yaml\n##[group]Run for file in $(whoami).txt; do\n    for file in $(whoami).txt; do\n        echo \"$file was changed\"\n    done\nshell: /usr/bin/bash -e {0}\n##[endgroup]\nrunner.txt was changed\n```\n\n### Impact\n\nThis issue may lead to arbitrary command execution in the GitHub Runner.\n\n### Resolution\n- A new `safe_output` input would be enabled by default and return filename paths escaping special characters like ;, ` (backtick), $, (), etc for bash environments.\n\n- A safe recommendation of using environment variables to store unsafe outputs.\n\n```yaml\n- name: List all changed files\n  env:\n    ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}\n  run: |\n    for file in \"$ALL_CHANGED_FILES\"; do\n      echo \"$file was changed\"\n    done\n```\n\n### Resources\n\n* [Keeping your GitHub Actions and workflows secure Part 2: Untrusted input](https://securitylab.github.com/research/github-actions-untrusted-input/)\n* [Keeping your GitHub Actions and workflows secure Part 1: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/)","aliases":["CVE-2023-51664"],"modified":"2026-09-15T06:32:39.990397341Z","published":"2024-01-02T16:41:27Z","database_specific":{"github_reviewed":true,"github_reviewed_at":"2024-01-02T16:41:27Z","nvd_published_at":"2023-12-27T17:15:08Z","cwe_ids":["CWE-74","CWE-77"],"severity":"HIGH"},"references":[{"type":"WEB","url":"https://github.com/tj-actions/changed-files/security/advisories/GHSA-mcph-m25j-8j63"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2023-51664"},{"type":"WEB","url":"https://github.com/tj-actions/changed-files/commit/0102c07446a3cad972f4afcbd0ee4dbc4b6d2d1b"},{"type":"WEB","url":"https://github.com/tj-actions/changed-files/commit/716b1e13042866565e00e85fd4ec490e186c4a2f"},{"type":"WEB","url":"https://github.com/tj-actions/changed-files/commit/ff2f6e6b91913a7be42be1b5917330fe442f2ede"},{"type":"PACKAGE","url":"https://github.com/tj-actions/changed-files"}],"affected":[{"package":{"name":"tj-actions/changed-files","ecosystem":"GitHub Actions"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"41"}]},{"type":"GIT","repo":"https://github.com/tj-actions/changed-files","events":[{"introduced":"0"},{"fixed":"716b1e13042866565e00e85fd4ec490e186c4a2f"}]}],"versions":["v41.0.0","v40.2.3","v40.2.2","v40.2.1","v40.2.0","v40.1.1","v40.1.0","v40.0.2","v40.0.1","v40.0.0","v40","v39.2.4","v39.2.3","v39.2.2","v39.2.1","v39.2.0","v39.1.2","v39.1.1","v39.1.0","v39.0.3","v39.0.2","v39.0.1","v39.0.0","v39","v38.2.2","v38.2.1","v38.2.0","v38.1.3","v38.1.2","v38.1.1","v38.1.0","v38.0.0","v38","v37.6.1","v37.6.0","v37.5.2","v37.5.1","v37.5.0","v37.4.0","v37.3.0","v37.2.0","v37.1.2","v37.1.1","v37.1.0","v37.0.5","v37.0.4","v37.0.3","v37.0.2","v37","v37.0.1","v37.0.0","v36.4.2","v36.4.1","v36","v36.4.0","v36.3.0","v36.2.1","v36.2.0","v36.1.0","v36.0.18","v36.0.17","v36.0.16","v35.9.2","v36.0.15","v36.0.14","v36.0.13","v36.0.12","v36.0.11","v36.0.10","v36.0.9","v36.0.8","v36.0.7","v36.0.6","v36.0.5","v36.0.4","v36.0.3","v36.0.2","v36.0.1","v36.0.0","v35.9.1","v35.9.0","v35.8.0","v35.7.12","v35.7.11","v35.7.10","v35.7.9","v35.7.8","v35.7.7","v35.7.6","v35.7.5","v35.7.4","v35.7.3","v35.7.2","v35.7.1","v35.7.0-sec","v35.7.0","v35.6.4","v35.6.3","v35.6.2","v35.6.1","v35.6.0","v35.5.6","v35.5.5","v35.5.4","v35.5.3","v35.5.2","v35.5.1","v35.5.0","v35.4.4","v35.4.3","v35.4.2","v35.4.1","v35.4.0","v35.3.2","v35.3.1","v35.3.0","v35.2.1","v35.2.0","v35.1.2","v35.1.1","v35.1.0","v35.0.1","v35.0.0","v34.6.2","v34","v34.6.1","v34.6.0","v34.5.4","v34.5.3","v34.5.2","v34.5.1","v34.5.0","v34.4.4","v34.4.3","v34.4.2","v34.4.1","v34.4.0","v34.3.4","v34.3.3","v34.3.2","v34.3.1","v34.3.0","v34.2.2","v34.2.1","v34.2.0","v34.1.1","v34.0.5","v34.0.4","v34.0.3","v34.0.2","v34.0.1","v34.0.0","v33.0.0","v33","v32.1.2","v32","v32.1.1","v32.1.0","v32.0.1","v32.0.0","v31.0.3","v31","v31.0.2","v31.0.1","v31.0.0","v30.0.0","v30","v29.0.9","v29","v29.0.8","v29.0.7","v29.0.6","v29.0.5","v29.0.4","v29.0.3","v29.0.2","v29.0.1","v29.0.0","v28.0.0","v28","v27","v26.1","v26","v25","v24.1","v24","v23.2","v23.1","v23","v22.2","v22.1","v22","v21","v20.2","v20.1","v20","v19.3","v19.2","v19.1","v19","v18.7","v18.6","v18.5","v18.4","v18.3","v18.2","v18.1","v18","v17.3","v17.2","v17.1","v17","v16","v15.1","v2.0.1","v12.2","v12.1","v2.0.0","v12","v11.9","v11","v1.3.1","v11.8","v1.3.0","v11.7","v1.2.2","v11.6","v1.2.1","v11.5","v1.2.0","v11.4","v11.3","v11.2","v11.1","v10.1","v10","v1.1.3","v1.1.2","v1.1.1","v1.1.0","v1.0.3","v1.0.2","v9.3","v9.2","v9.1","v9","v8.9","v8.8","v8.7","v8.6","v8.5","v8.4","v8.3","v8.2","v8.1","v8","v7","v6.3","v6","v6.2","v6.1","v5.3","v5.2","v5.1","v5","v4.4","v4.3","v4.2","v4.1","v4","v3.3","v3.2","v3.1","v3","v2.1","v2","v1"],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2024/01/GHSA-mcph-m25j-8j63/GHSA-mcph-m25j-8j63.json"}}],"schema_version":"1.9.0","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:N"}]}