Skip to content
RCE Advisory Intermediate

GHSL-2023-271: Arbitrary command execution in changed-files

The changed-files GitHub Action did not properly escape special characters in filenames, allowing an attacker to inject commands via a crafted filename. If the output was used in a run block, this could lead to arbitrary command execution on the GitHub Runner and potential secret theft.

ghsecuritylab Follow

Originally disclosed on GitHub Security Lab

The tj-actions/changed-files workflow allows for command injection in changed filenames, allowing an attacker to execute arbitrary code and potentially leak secrets.

ghsecuritylab, on GitHub Security Lab

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Impact

This issue may lead to arbitrary command execution in the GitHub Runner, and an attacker could steal secrets such as GITHUB_TOKEN if triggered on events other than pull_request, for example on push.

What the attacker needed

A GitHub repository using the action; attacker can submit a pull request; workflow approval required; output used in a run block

The fix

The issue was fixed in commit 0102c07.

How it was found

  1. Submit a pull request with a new file whose name contains a command injection payload.
  2. Approve the workflow triggered by the pull request.
  3. The action runs and the malicious filename flows into a step that uses the output in a run block, executing the injected command.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A GitHub Action is a tool that runs automatically when code changes. This action lists changed files, but it didn't clean up special characters in filenames. An attacker could name a file something like `$(whoami).txt`, and if the action's output was used in a script, the command inside the filename would run on the server.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More by ghsecuritylab

View all

132 more disclosed reports, best first.

More from GitHub Security Lab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.