New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CVE-2022-24439: <gitpython::clone> 'ext::sh -c touch% /tmp/pwned'
for remote code execution
#1515
Comments
I am aware, have been informed and we can track it here. Thanks a lot for setting up this issue so timely. |
<gitpython::clone> 'ext::sh -c touch% /tmp/pwned'
for remote code execution
@Byron, had Snyk or Sam Wheating (@SamWheating?) contacted you previously about this or did you learn about it independently? I'm curious given there's no reference to any upstream report in the above Snyk report. |
I reached out to Snyk, who I believe got in touch with the maintainers. |
What makes you think that? Again, just curious given there doesn't seem to be any indication of that happening according to their report. Also, why did you go to Snyk rather than to upstream? |
Snyk did reach out to me by email, to my mind all this went pretty well. By publishing the issue the community can contribute a mitigation. |
Yeah, seems fine to me. It would have been nice to have an existing public report to go with the public release of the CVE so that all the people who handle CVEs (myself, and the reporter of this issue, for example) would know that the issue is already known to upstream and we don't have to spend time extracting that information via issues like this. Thank you for the insight. |
Looks like this same vulnerability has been reported in another git library (simple-git), https://www.cve.org/CVERecord?id=CVE-2022-25912. They added an option to opt-in in to the insecure behavior
And this should probably check for https://www.cve.org/CVERecord?id=CVE-2022-24433 too ( |
Snyk's vulnerability program is fantastic - you can report an issue to them and they will review it, triage it, try to get in contact with the maintainers and then register the CVE if applicable. It eliminates a lot of the overhead on my end and helps to ensure that a vulnerability is handled appropriately. I didn't have a direct line to the maintainers and I didn't want to open a public issue explaining a potentially sensitive vulnerability. In this case it sounds like Snyk was able to get in touch on my behalf and handle this disclosure responsibly. |
Just thought I would ping to keep this issue active. This is a critical issue in my org. Can we get a status update? Is a fix expected soon? |
|
Since the URL is passed directly to git clone, and the remote-ext helper will happily execute shell commands, so by default qoute URLs unless a (undocumented, on purpose) kwarg is passed. (CVE-2022-24439) Fixes gitpython-developers#1515
Since the URL is passed directly to git clone, and the remote-ext helper will happily execute shell commands, so by default disallow URLs that contain a "::" unless a new unsafe_protocols kwarg is passed. (CVE-2022-24439) Fixes gitpython-developers#1515
Since the URL is passed directly to git clone, and the remote-ext helper will happily execute shell commands, so by default disallow URLs that contain a "::" unless a new unsafe_protocols kwarg is passed. (CVE-2022-24439) Fixes gitpython-developers#1515
To avoid part of the problem, gitpython should also avoid interpreting positional arguments as option arguments. Line 1244 in 17ff263
but there are commands like git checkout that make special use of Other options could be:
|
Am I the only one confused by trying to fix a problem in the underlying Trying to do that, to my mind, will not deter an attacker who wants to find a bypass, and is much more likely to break downstream legitimate code, or use-cases for the now deemed unsafe features. There is clearly a tradeoff that seems impossible to get right.
Those who pass user-input to |
we're using this in eze https://github.com/RiverSafeUK/eze-cli
|
Thanks for sharing! Have you validated that URL injection works? After all the shell seems to be disabled by default and isn't enabled when calling clone either. Without shell in the middle a url like this should be just a single string passed to
For a moment I thought maybe |
Don't you agree that methods like clone that are expecting a path/url Line 1219 in 17ff263
--foo and that's interpreted as an option, that is unexpected/wrong.
|
I agree, and now I understand what the prior comment is about as well. And it seems not too unlikely that I think once it can be demonstrated that one can indeed execute programs on the server by manipulating the URL or maybe even the URL + destination path, that would be an issue specific to |
That's already possible, and with normal repos, not only ssh repos. The command is executed on the machine that executes gitpython. import git
r = git.Repo.init('/tmp/test', bare=True)
r.clone("--upload-pack=touch /tmp/pwn") |
That I find really bad, and even though |
Since the URL is passed directly to git clone, and the remote-ext helper will happily execute shell commands, so by default disallow URLs that contain a "::" unless a new unsafe_protocols kwarg is passed. (CVE-2022-24439) Fixes gitpython-developers#1515
Since the URL is passed directly to git clone, and the remote-ext helper will happily execute shell commands, so by default disallow URLs that contain a "::" unless a new unsafe_protocols kwarg is passed. (CVE-2022-24439) Fixes gitpython-developers#1515
Since the URL is passed directly to git clone, and the remote-ext helper will happily execute shell commands, so by default disallow URLs that contain a "::" unless a new unsafe_protocols kwarg is passed. (CVE-2022-24439) Fixes gitpython-developers#1515
I'm not sure I have much to contribute to the conversation or to a fix. I did want to offer a lamentation that git doesn't have a C library to tie into to avoid having to execute the git cli instead of working against a library instead for this. |
The library for |
Well, it does (https://libgit2.org/), doesn’t it? |
I assume @blade2005 meant that there is no native |
@Byron Could you please confirm if this PR #1518 is fixing CVE-2022-24439 issue as it has been added to 3.1.30 ? |
@nrpt-m I second that. |
A new release was created to incorporate many security related fixes. A special thanks goes to @stsewd who was a driving force behind implementing the fixes, and to the fine folks who discovered it. I hope this makes the upcoming year 2023 a little more secure for everyone |
Can a release be made in Github? I imagine a nonzero number of people are watching for releases in this repository who aren't subscribed to this issue to be aware of the security impact of this release. |
Thanks for the hint. That should be done now. |
* Update requirements from branch 'master' to 2aaf64dd91c63aa55f4cbe8c037a6f545e91b302 - Merge "Bump GitPython to 3.1.30" - Bump GitPython to 3.1.30 3.1.30 includes 2 sets of fixes for CVE-2022-24439: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-24439 gitpython-developers/GitPython#1515 PRs: gitpython-developers/GitPython#1518 gitpython-developers/GitPython#1521 Signed-off-by: Lon Hohberger <[email protected]> Change-Id: I0def2d9801f0b20fcc9b613165a29dbced1fd2d7
3.1.30 includes 2 sets of fixes for CVE-2022-24439: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-24439 gitpython-developers/GitPython#1515 PRs: gitpython-developers/GitPython#1518 gitpython-developers/GitPython#1521 Signed-off-by: Lon Hohberger <[email protected]> Change-Id: I0def2d9801f0b20fcc9b613165a29dbced1fd2d7
3.1.30 - Make injections of command-invocations harder or impossible for clone and others. See gitpython-developers/GitPython#1518 for details. Note that this might constitute a breaking change for some users, and if so please let us know and we add an opt-out to this. - Prohibit insecure options and protocols by default, which is potentially a breaking change, but a necessary fix for gitpython-developers/GitPython#1515. Please take a look at the PR for more information and how to bypass these protections in case they cause breakage: gitpython-developers/GitPython#1521.
This appeared in the CVE feed today: https://security.snyk.io/vuln/SNYK-PYTHON-GITPYTHON-3113858
Not sure if this was reported to you before or not, reporting it here just in case.
The text was updated successfully, but these errors were encountered: