| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks a lot for the preview - I see now how this can work and like that it seems to be minimally invasive overall.
I assume that the testing will primarily be done by hand for ease of use but hope that some sort of 'practical' test-case could be contributed as well.
Sorry, something went wrong.
|
I would like to write tests, I looked around through the test suite, but it still escapes me how to structure these tests. Since these options affect how git is executed, it seems like it would have to connect to the network? Or is there a test that already replaces the protocol helper, e.g. git-remote-https, to avoid network access? |
Sorry, something went wrong.
|
It really isn't easy to test it at all, and probably impossible to test it exhaustively. So I am fine admitting defeat on this one, particularly because the tests I could imagine would be so specific and spotty that they barely have any value. |
Sorry, something went wrong.
|
if we can only run git, that could mean we pick #2027 over #2026. I don't think it makes sense to have an allowlist of other executables GitPython could run. @EliahKagan, your thoughts? |
Sorry, something went wrong.
I haven't reviewed this draft PR in detail, and I also don't know what it will be like and how it will document the "safe mode" feature once it's done. But my first impression is that the changes being proposed here should not directly impose any requirements on whether is_cygwin_git runs an external subprocess besides git:
However, that may not be the whole story. Although I don't think "safe mode" should prohibit the use of subprocesses in is_cygwin_git, it may be that they should be avoided in general when not needed for the same reasons. As currently written, it takes some effort to verify that is_cygwin_git does not introduce an untrusted search path vulnerability. Furthermore, regarding the use of uname in is_cygwin_git, while I think it's probably not a vulnerability, it's not really ideal to assume adjacent executables are similarly trusted. It might be considered a valuable security enhancement to avoid assuming that just because an executable has a standard name and resides in the same directory as git that it is safe or reasonable to execute it. |
Sorry, something went wrong.
There was a problem hiding this comment.
I noticed a couple of things related to unusual but plausible command arguments.
Sorry, something went wrong.
|
FYI this is my very simple test suite: #!/usr/bin/python3
import os
import git
import tempfile
for url in [
'git@gitlab.com:fdroid/ci-test-app.git',
'ssh://gitlab.com/fdroid/ci-test-app.git',
'git://gitlab.com/fdroid/ci-test-app.git',
]:
print('====================', url)
d = tempfile.mkdtemp(prefix='foo_py_')
repo = git.Repo.clone_from(url, d, safe=True)
# clone from fake URL should prompt for password
d = tempfile.mkdtemp(prefix='foo_py_')
for url in [
'https://github.com/asdfasdfasdf/adsfasdfasdf.git',
'https://gitlab.com/asdfasdfasdf/adsfasdfasdf.git',
'https://codeberg.org/asdfasdfasdf/adsfasdfasdf.git',
]:
try:
repo = git.Repo.clone_from(url, d, safe=True)
except git.exc.GitCommandError as e:
print('repo', e)
url = 'https://gitlab.com/fdroid/ci-test-app.git'
d = tempfile.mkdtemp(prefix='foo_py_')
print(d)
repo = git.Repo.init(d, safe=True)
origin = repo.create_remote("origin", url)
origin.fetch()
d = tempfile.mkdtemp(prefix='foo_py_')
print(d)
repo = git.Repo.clone_from(url, d, safe=True)
print(type(repo))
print('SUCCESS') |
Sorry, something went wrong.
|
I think I should leave it to @EliahKagan to review this PR, due to its nature of being very relevant to the security of the project. To me it still is the question if there is a good case for supporting this - I'd think the answer should be "yes" if f-droid benefits, but I fear that it lures people into a false sense of safety. Maybe safe=true should be changed to something more specific at the very least, because it's definitely not safe by all means. |
Sorry, something went wrong.
|
F-Droid has been using this approach for years, and will switch to this code once it is merged. As for the name, I'm open to suggestions. I used the word "safe" following the example of parser libs I've seen, where it means features are disabled in the interest of security. Like ruamel.yaml uses "safe" mode to mean a YAML parser that does not parse anything but lists, dicts, and scalars (e.g. no objects). From what see, I think this clearly does make it safer to use. |
Sorry, something went wrong.
There was a problem hiding this comment.
I'll try to review this in full sometime soon! This mini-review is not that. Instead, this just points out a couple of things related directly to my previous comments. One is fairly minor and pertains to the clarity and technical accuracy of exception messages. The other is more significant: the current attempt to refuse to run the command in a shell does not always work.
Sorry, something went wrong.
|
I think this is ready to go. Let me know if there is anything I can provide to help with the review and merge. |
Sorry, something went wrong.
This code already depends on GitPython, and hopefully the common.vcs* stuff can eventually go away entirely. GitPython should provide those bits already, and they are maintained by someone else. gitpython-developers/GitPython#2029
|
@EliahKagan anything I can help with? Any other blockers here? I rebased this on the latest main. |
Sorry, something went wrong.
|
The test failure seems to be unrelated, something with it can't connect to localhost |
Sorry, something went wrong.
|
@eighthave Sorry for the long wait. The test might be flaky, and fixing the conflicts will hopefully resolve this. |
Sorry, something went wrong.
|
Also converting to draft as there seem to be more subtle issues with this PR that Eliah can elaborate when there is time. |
Sorry, something went wrong.
|
I rebased this on main.
Happy to fix issues if I know what they are. FYI, we've been using a version of
this code in production for a while now and have seen no problems with it.
|
Sorry, something went wrong.
|
While it's desirable what's attempted here, the PR is stale and it's better to start over. |
Sorry, something went wrong.
|
At this point, it seems the GitPython maintainers do not want this, I just wish
things were stated clearly. I've responded to all requests and rebased as
needed. Without a clear commitment from the GitPython maintainers, I won't
pursue this further in GitPython. Instead, we will continue to maintain it in
fdroidserver.
|
Sorry, something went wrong.
|
My apologies, the GitPython maintainers are a bit overwhelmed and wanted to clear the slate. Can it be useful even without being perfect? Red CI can probably be fixed quickly these days, something @eighthave wants to do, or should I push into it? Also, what's missing from getting this out of draft? A task list/checkbox list would help with this if it's nothing quick. |
Sorry, something went wrong.
|
I'm very sorry about my poor communication here. I have substantial notes about this, but I don't know when I'll be able to get back to it and I don't want to keep saying "soon." There are subtleties that arise when bringing this into GitPython in this form. I am worried that--unintuitive as it may seem--this may actually introduce new or exacerbate existing vulnerabilities in GitPython or other software if added to GitPython like this, or in any patch based on the proposal in #2020. One of the reasons I failed to respond is that I didn't want to make vague and potentially ominous-sounding statements like what I am doing in this comment. But I want to make clear that I do not recommend moving forward on this in GitPython at this time. This relates to multiple intersecting lines of security research, some of which have themselves been taking longer than expected for unrelated reasons. Out of an abundance of caution, I do not think that it is acceptable for me to say anything more about this right now. If I can get the time, and if I identify and confirm vulnerabilities in GitPython or other projects, then I will report them. |
Sorry, something went wrong.
|
I am also very sorry for all the hassle and… the flip-flopping. It's all based on my lossy memory. To recount, @EliahKagan already brought up concerns about this PR and started working on the security implications with the goal of making it better. It was at this point where we should have asked if we want to invest the time, or just close it. Over time, all that was left with me is the sentiment that this PR should be closed, without much information backing it. The OP's response then shook my resolve and my uncertainty led me to back-paddle, forcing Eliah to come to action. But all of this doesn't change the sentiment, the issues found with this PR, and the time it would take to make it mergable. Thus, it's best to close it, focussing our very limited resources elsewhere. Sorry again for the hassle, and thanks for your understanding, to both of you, @EliahKagan and @eighthave. PS: My recent cleanup is also to avoid long-standing PRs in future, and to be way faster in either fixing issues and merging PRs, or to close them, to prevent a buildup of what later will be noise and that overwhelming feeling that one is lacking behind. |
Sorry, something went wrong.
|
@EliahKagan could you at least send me your notes privately so we can decide how
to proceed? Our approach here has been in place in our code base for years and
has been audited. If you know of existing issues, we need to fix them. It
would be helpful even if it was just raw notes without explanation.
***@***.*** is the email in my commits and matches my longstanding public PGP key:
EE66 20C7 136B 0D2C 456C 0A4D E9E2 8DEA 00AA 5556
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
As described in #2020, here is the core implementation of "safe mode". The core idea is to set up operations so that external programs are not executed by git. This has been a major source of vulnerabilities.
This means that network connections are limited to HTTPS. As much as possible, this will rewrite remote URLs to HTTPS. This is necessary so that submodules work even when they do not use HTTPS URLs, as long as they are public, HTTPS-accessible repos.
This is a draft to confirm the approach. Then I will follow up and polish everything for merging.
closes #2020