code injection vulnerability exists in the huggingface/text-generation-inference repository
The autodocs.yml workflow used the pull request branch name (github.head_ref) to build a shell command without sanitising it. An attacker could fork the repository, create a branch with a malicious name, and open a pull request to run arbitrary code on the GitHub Actions runner.
huggingface/text-generation-inference
Originally disclosed on huntr
A code injection vulnerability exists in the huggingface/text-generation-inference repository, specifically within the autodocs.yml workflow file. The vulnerability arises from the insecure handling of the github.head_ref user input, which is used to dynamically construct a command for installing a software package. An attacker can exploit this by forking the repository, creating a branch with a malicious payload as the name, and then opening a pull request to the base repository. Successful exploitation could lead to arbitrary code execution within the context of the GitHub Actions runner. This issue affects versions up to and including v2.0.0 and was fixed in version 2.0.0.
From the GitHub Advisory Database (GHSA-qq99-p57r-g3v7, CC BY 4.0).
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
Root cause
Likely the workflow interpolated the untrusted github.head_ref value directly into a shell command without quoting or validation, allowing command injection.
Impact
Successful exploitation could lead to arbitrary code execution within the context of the GitHub Actions runner.
What the attacker needed
Ability to fork the repository; ability to open a pull request
The fix
The issue was fixed in version 2.0.0.
How it was found
- Fork the repository.
- Create a branch whose name contains a malicious payload.
- Open a pull request from that branch to the base repository.
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 workflow file tells GitHub's automation servers what to do when someone opens a pull request. Here it took the name of the attacker's branch and pasted it into a command, so a branch name containing shell instructions would be executed. That let the attacker run their own code on the automation server.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.