Prefect has Git Flag Injection via commit_sha and directories Parameters Leading to Remote Code Execution (RCE)
The GitRepository storage class in Prefect passed user-controlled commit_sha and directories values to git commands without validation or a -- separator, allowing git flag injection. An attacker with deployment creation permissions could inject flags such as --upload-pack to execute arbitrary commands on worker machines.
prefecthq/prefect
Originally disclosed on huntr
Prefect versions 3.1.11 through 3.6.24 are vulnerable to remote code execution due to improper handling of user-controlled input in the GitRepository storage class. The commit_sha parameter, which is passed to git commands, lacks validation and does not include a -- separator to distinguish user input from git flags. This allows attackers to inject arbitrary git flags, such as --upload-pack, enabling execution of external programs. Additionally, the directories parameter can be exploited to inject git flags during sparse-checkout operations. These vulnerabilities allow any user with deployment creation permissions to execute arbitrary commands on worker machines, compromising shared work pools in multi-tenant environments.
From the GitHub Advisory Database (GHSA-7pm4-56h2-5rxr, 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 user-controlled commit_sha and directories values were passed to git commands without validation and without a -- separator, so they were interpreted as git flags.
Impact
Any user with deployment creation permissions could execute arbitrary commands on worker machines, potentially compromising shared work pools in multi-tenant environments.
What the attacker needed
Deployment creation permissions
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.
Prefect is a workflow tool that can pull code from a Git repository. It took a user-supplied commit identifier and folder list and handed them straight to the git program without saying 'this is data, not an option'. Because git treats some strings starting with dashes as options, an attacker could sneak in an option that makes git run a program of their choosing on the worker machine.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.