Skip to content
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

fatal: unsafe repository ('...' is owned by someone else) and impact of CVE-2022-24765 fix for git #707

Closed
KOLANICH opened this issue Apr 13, 2022 · 10 comments

Comments

@KOLANICH
Copy link

Hi. Today I have noticed that editable installation of packages from root stopped working. It is because of git version with fix for CVE-2022-24765 has been released and delivered.

It writes that LookupError: setuptools-scm was unable to detect version for ....

Investigation and adding dumping resulted in pinpointing the error to .git.from_potential_worktree, where git errors with

fatal: unsafe repository ('...' is owned by someone else)

To add an exception for this directory, call:
	git config --global --add safe.directory

.

  1. I know that editable installs from root are insecure and that just adding files to such dirs allows privelege escallation.
  2. I know that pip must not execute wheel building elevated even if called from root, it should drop its rights for the time it builds wheel, and it is a flaw in pip it doesn't do that.

But those are not flaws in setuptools_scm. Let's concentrate on the flaws on setuptools_scm related to the issue.

@KOLANICH
Copy link
Author

The workaround to this issue is to use sudo fakeroot instead of sudo. fakeroot makes git think that the repo is owned by root, and so the security check is satisfied.

@pitrou
Copy link

pitrou commented Apr 22, 2022

I suspect many people are affected by this. It happens for example when running a Docker container where the source tree is mounted from the host.

@pitrou
Copy link

pitrou commented Apr 22, 2022

@henryiii @RonnyPfannschmidt What would be your take on this?

@RonnyPfannschmidt
Copy link
Contributor

@pitrou thanks for the linked issue,

I believe it may be good/necessary to pass that config option to git

I'll make it a Fokus roughly mid next week after completing git archive support

@KOLANICH
Copy link
Author

I believe it may be good/necessary to pass that config option to git

The doc says that config option takes no effect when passed through command line. Modifying configs is IMHO inacceptable. IMHO the solution with fakeroot and/or using bindings to more flexible git libs is more optimal.

@pitrou
Copy link

pitrou commented Apr 22, 2022

@KOLANICH Can you point to the doc that says that?

@pitrou
Copy link

pitrou commented Apr 22, 2022

@pelson
Copy link
Contributor

pelson commented Apr 25, 2022

Saw the same issue. An unsafe fix is git config --global --add safe.directory '*'. This is perfectly fine in my case, as it is for CI purposes.

Setting SETUPTOOLS_SCM_DEBUG=1 was essential for diagnosing this issue - perhaps the best place to start would be to try to catch this message and make it easier to know about the issue in setuptools-scm.

In general, I agree that this is likely to come up more frequently for container use-cases once the newer git CLI is more prevalent.

@chrisburr
Copy link
Contributor

Looking at the implementation in setuptools_scm.git it should be fairly straight forward to workaround this issue using --git-dir=... or by setting $GIT_DIR.

I'll try to make a pull request this afternoon.

dtrifiro added a commit to iterative/dvc-s3-repo that referenced this issue Apr 29, 2022
dtrifiro added a commit to iterative/dvc-s3-repo that referenced this issue Apr 29, 2022
efiop pushed a commit to iterative/dvc-s3-repo that referenced this issue Apr 29, 2022
njzjz added a commit to njzjz/deepmd-kit-test-environment that referenced this issue May 17, 2022
messense added a commit to messense/setuptools-rust that referenced this issue May 30, 2022
@RonnyPfannschmidt
Copy link
Contributor

resolved in the latest release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants