REDHAT-BUG-2510021: High severity GitPython GitPython vulnerability
GitPython before 3.1.52 is vulnerable to environment-variable exfiltration in Repo.clonefrom(). The caller-supplied remote URL is passed through Git.polishurl(), which on non-Cygwin platforms calls os.path.expandvars() on the URL before invoking git clone. An attacker who controls the clone URL can embed $NAME or ${NAME} tokens that are expanded to the values of the hosting process's environment variables (e.g., AWSSECRETACCESSKEY or GITHUBTOKEN). The resulting URL, now containing the secret, is transmitted over the network to an attacker-controlled host during the clone attempt, disclosing the secret.
Affected Software
Event History
Frequently Asked Questions
Who is exposed to this issue?
Applications using GitPython before 3.1.52 are exposed when they pass an attacker-controlled remote URL to Repo.clone_from() on a non-Cygwin platform. The hosting process is at risk of disclosing environment variables available to that process.
What does an attacker need to exploit it?
An attacker needs control over the remote URL supplied to Repo.clone_from(). They can place $NAME or ${NAME} tokens in that URL so GitPython expands them before git clone sends the resulting URL to an attacker-controlled host.
What information can be disclosed?
Any environment-variable value available to the hosting process may be included in the outbound clone URL. Examples in the affected behavior include AWS_SECRET_ACCESS_KEY and GITHUB_TOKEN.
How can exposure be reduced if updating is not immediately possible?
Do not allow untrusted parties to control URLs passed to Repo.clone_from(). Also avoid running the hosting process with unnecessary secrets in its environment, because values available there can be expanded into the clone URL.