git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Limitations of ownership checking fox for CVE-2022-24765

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Apr 13, 2022, 14:05 UTC
Message-ID
<220413.86v8vdf46n.gmgdl@evledraar.gmail.com>
In-Reply-To
<CAKJfoCEgiNvQJGt=rGYTaKQ1i2ihrPmX2Sz3Zxg-y66L+1Qh6g@mail.gmail.com>
On Tue, Apr 12 2022, Jeremy Maitin-Shepard wrote:
Show 9 quoted lines
> The current fix for CVE-2022-24765 prevents unsafe command execution
> in some cases but does not address all cases:
>
> - Ownership by the current user should not be taken to mean "trusted":
> the user may have retrieved a directory tree from an untrusted source,
> including:
>   - Another version control system (which won't prevent a .git directory)
>   - Unpacking an archive
>   - FUSE mounting a remote filesystem

Those would be good to fix, but I don't think it's correct that it's within the scope of CVE-2022-24765.

That CVE is specifically about the multi-user case where we'd previously pick up another user's .git directory.

Whereas these cases aren't like that in that they:
1) Require the user to have set up that .git directory themselves, in
   one way or another.
2) ...or for the OS to enforce user permissions so loosely that others
  can chown files as you.
> Additionally, the current fix requires additional configuration to
> support existing use cases, and does not provide uses a way to safely
> execute commands like `git status` or `git log` on untrusted
> repositories.

Yes, I agree. I.e. that the method of fixing it is all-or-nothing, and therefore creates escalation issues that wouldn't occur with a narrower approach.

There was extensive off-list discussion about this, my [1] touches some
of it. To quote my side of a discussion following-up [1] about the more
narrow approach:
	
	An implementation that asks the user to create an opt-in for any and all
	config will be much less secure for the core.sharedRepository case,
	which is an edge case my proposed change on top doesn't have.
	
	That's because we'll refuse to read *any* config (including just that
	created by "git init"), and then ask the user to opt-in to any *future*
	config to keep using the repository at all.
	
	So for the sort of staging environment I mentioned upthread it'll
	effectively create a vulnerability which we'll still have no practical
	mitigation for.
	
	Whereas if we only error on the specific exploitation vector(s) users
	who're using a repository without such config will never need to opt-in
	at all, so when someone sneaks up on them later and adds a
	core.fsmonitor=/path/to/exploit they'll know, and we can show a much
	more pointed and obvious error to that effect.

As noted in [1] the solution that got committed does suffer from that edge case, but I think [1] also summarizes why that approach was taken.

A way of mitigating that case is to put something like this in one's .bashrc:

	git () {
		command git -c core.fsmonitor=false "$@";
	}

Then, even if you need to use that safe.directory feature you won't be vulnerable to someone sneaking up on you and adding this to the .git/config of the (presumably core.sharedRepository) repo:

    [core]
    fsmonitor = rm -rf /
Show 10 quoted lines
> I think a better solution would be for git to support a `--safe`
> option that only runs config-specified commands specifically added to
> an allowed list, or if the repository itself has been added to
> safe.directories.
>
> Ideally git would default to running in `--safe` mode, but if that is
> too disruptive at least the option would be available for use in
> prompt commands, etc.
>
> (Please CC me in replies as I'm not subscribed to the list.)

What you're suggesting would be nice, and has been discussed on-list before.

But it's fundamentally the same case as "make inspecting an unpacked .git [from a tarball] safe", i.e. that we'll currently pick up config from it.

The CVE specifically exists because it's subtly different from that long-known-about case.

1. https://lore.kernel.org/git/220412.86h76yglfe.gmgdl@evledraar.gmail.com/
Previous: Jeremy Maitin-ShepardNext: Jeremy Maitin-Shepard
Message 2 of 4 in “Limitations of ownership checking fox for CVE-2022-24765”
  1. Jeremy Maitin-ShepardApr 13, 2022
  2. Ævar Arnfjörð BjarmasonApr 13, 2022
  3. Jeremy Maitin-ShepardApr 13, 2022
  4. Ævar Arnfjörð BjarmasonApr 13, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.