Git 2.35.2, released on April 12, 2022, changes how Git treats repositories owned by another user. By default, Git refuses to read their repository configuration or run their hooks. The security fix also affects deliberately shared checkouts on multi-user machines. For teams upgrading developer and build machines, restoring access requires an explicit trust exception—not a setting added inside the repository itself. [S1][S2][S4]
The problem, tracked as CVE-2022-24765, can surface without someone deliberately opening an unfamiliar project. Git’s security notes describe a repository created by another user in a shared location, such as a network drive or scratch space. A Git-aware shell prompt or editor can then invoke Git and potentially run commands configured by that other user. GitHub’s release explanation says version 2.35.2 stops its upward search for a repository when directory ownership changes away from the current user. [S3][S4]
The new safe.directory setting provides a way to name exceptions for repositories that are intentionally shared. In the 2.35.2 documentation, it is a multi-valued setting: users can add more than one directory with git config --add. This is a trust decision about a directory owned by somebody else, not a repair to the project’s files. An administrator should establish who controls the shared checkout before treating the ownership mismatch as harmless. [S2]
Where that exception is stored matters. Git 2.35.2 respects safe.directory only in system or global configuration. The same setting in the repository’s own configuration is ignored, as is a command-line override using -c safe.directory=<path>. A workaround copied into a build command can therefore leave the job blocked. For this release, the account running Git needs the exception in one of the documented configuration locations. [S2]
There is also a way to replace an inherited list rather than keep extending it. The versioned documentation says an empty safe.directory entry resets the list, including directories supplied by system configuration. A team maintaining workstation or build-account setup instructions should distinguish adding an approved shared path from resetting existing exceptions; they are different changes to which repositories Git will trust. [S2]
Check the tools that launch Git as well as the people who type its commands. GitHub’s April 12 advisory names shell and development tools that invoke Git behind the scenes and warns users on multi-user machines to avoid those tools until upgrading. The practical rollout check is whether each execution account can work with its intended repositories after the patch, with shared-directory exceptions approved explicitly. An ownership error is a reason to check that directory’s owner, not to trust every shared location. [S4][S2]
Source documents
- Git v2.35.2 release noteshttps://raw.githubusercontent.com/git/git/v2.35.2/Documentation/RelNotes/2.35.2.txt
- Git v2.35.2 safe.directory configuration documentationhttps://raw.githubusercontent.com/git/git/v2.35.2/Documentation/config/safe.txt
- Git security fixes: Documentation/RelNotes/2.30.3.txt at v2.35.2https://raw.githubusercontent.com/git/git/v2.35.2/Documentation/RelNotes/2.30.3.txt
- Git security vulnerability announced — GitHub, April 12, 2022https://github.blog/2022-04-12-git-security-vulnerability-announced/
