Skip to content

mingw: skip symlink type auto-detection for network share targets - #2189

Open
dscho wants to merge 1 commit into
gitgitgadget:masterfrom
dscho:skip-symlink-detection-for-network-shares
Open

mingw: skip symlink type auto-detection for network share targets#2189
dscho wants to merge 1 commit into
gitgitgadget:masterfrom
dscho:skip-symlink-detection-for-network-shares

Conversation

@dscho

@dscho dscho commented Jul 28, 2026

Copy link
Copy Markdown
Member

This was released as part of Git for Windows v2.53.0(3) already.

@gitgitgadget

gitgitgadget Bot commented Jul 28, 2026

Copy link
Copy Markdown

There is an issue in commit 330f153:
mingw: skip symlink type auto-detection for network share targets

  • Lines in the body of the commit messages should be wrapped between 60 and 76 characters.
    Indented lines, and lines without whitespace, are exempt

@dscho

dscho commented Jul 28, 2026

Copy link
Copy Markdown
Member Author

/submit

@gitgitgadget

gitgitgadget Bot commented Jul 28, 2026

Copy link
Copy Markdown

There is an issue in commit 330f153:
mingw: skip symlink type auto-detection for network share targets

  • Lines in the body of the commit messages should be wrapped between 60 and 76 characters.
    Indented lines, and lines without whitespace, are exempt

On Windows, symbolic links come in two flavors: file symlinks and
directory symlinks.  Since Git was born on Linux where this distinction
does not exist, Git for Windows has to auto-detect the type by looking
at the target.  When the target does not yet exist at symlink creation
time, Git for Windows creates a "phantom" file symlink and later, once
checkout is complete, calls `CreateFileW()` on the target to check
whether it is actually a directory.

If the symlink target is a UNC path (e.g. `\\attacker\share`), this
auto-detection triggers an SMB connection to the remote host.  Windows
performs NTLM authentication by default for such connections, which
means a crafted repository can exfiltrate the cloning user's NTLMv2 hash
to an attacker-controlled server without any user interaction beyond
`git clone -c core.symlinks=true <url>`.

There are ways to specify UNC paths that start with only a single
backslash (e.g. `\??\UNC\host\share`); All of them do start like that,
though, so let's use that as a tell-tale that we should skip the
auto-detection in `process_phantom_symlink()`. The symlink is then left
as a file symlink (the `mklink` default), and a warning is emitted
suggesting the user set the `symlink` gitattribute to `dir` if a
directory symlink is needed.  When the attribute is already set,
auto-detection is never invoked in the first place, so that code path is
unaffected.

This is the same class of vulnerability as CVE-2025-66413
(GHSA-hv9c-4jm9-jh3x)
and follows the same general mitigation pattern that MinTTY adopted for
ANSI escape sequences referencing network share paths
(GHSA-jf4m-m6rv-p6c5).

Note that there are legitimate paths starting with a single backslash
that are _not_ network paths: drive-less absolute paths are interpreted
as relative to the current working directory's drive. In practice, these
are highly uncommon (and brittle, just one working directory change away
from breaking). In any case, the only consequence is now that the
symlink type of those has to be specified via Git attributes, is all.

Reported-by: Justin Lee <jessdhoctor@gmail.com>
Addresses: CVE-2026-32631
Assisted-by: Claude Opus 4.6
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho
dscho force-pushed the skip-symlink-detection-for-network-shares branch from 330f153 to 19ae3c7 Compare July 28, 2026 11:44
@dscho

dscho commented Jul 28, 2026

Copy link
Copy Markdown
Member Author

/submit

@gitgitgadget

gitgitgadget Bot commented Jul 28, 2026

Copy link
Copy Markdown

Submitted as pull.2189.git.1785239196007.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-2189/dscho/skip-symlink-detection-for-network-shares-v1

To fetch this version to local tag pr-2189/dscho/skip-symlink-detection-for-network-shares-v1:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-2189/dscho/skip-symlink-detection-for-network-shares-v1

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant