/

CVE-2026-42305

Severity:

HIGH RISK

(8.8)

Path Traversal (CWE-22) in Dulwich Git on Windows

CVE-2026-42305

Deferred

Vulnerability type

Category:

Path Traversal / Arbitrary File Write

CWE:

CWE-22

Impact:

Arbitrary File Write leading to Remote Code Execution

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Dulwich, a pure-Python Git implementation, contains a path traversal flaw on Windows that allows arbitrary file writes during clone, fetch, or checkout of a malicious repository.

An attacker who controls repository contents can craft filenames that bypass NTFS path protections, potentially leading to remote code execution on affected Windows systems.

Affected context

The vulnerability occurs when Dulwich is used to clone, fetch, or check out Git repositories on Windows systems.

It is relevant to any workflow that:

  • Processes untrusted or third-party Git repositories
  • Uses Dulwich directly via its CLI, porcelain.clone, or downstream tools that embed Dulwich
  • Runs on Windows filesystems that interpret special path syntax (e.g., NTFS)

POSIX environments are not directly exploitable but can unknowingly propagate malicious trees that later impact Windows users.

Exploit preconditions

  • Attack surface: Git repository content processed by Dulwich on Windows.
  • Required access: Ability to publish, push, or otherwise supply a malicious repository that a victim will clone, fetch, or check out with Dulwich.
  • Trigger point: Repository operations that materialize tree entries onto disk (clone, fetch + checkout, or similar).
  • Why exploitation is possible: Dulwich's filename validation accepted path elements containing bytes that Windows treats as structural path syntax, and configuration-based protections (core.protectNTFS, core.protectHFS) were misread and effectively disabled, allowing crafted filenames to escape intended directory boundaries and overwrite arbitrary files.

Why this happens

The root cause is incomplete and misconfigured path validation when translating Git tree entries into filesystem paths on Windows.

Dulwich's path-element validator failed to reject filenames containing bytes that NTFS interprets as special path components, enabling directory traversal or placement of files in unintended locations (CWE-22).

Contributing to this, the protective configuration flags were looked up under incorrect option names, so user settings were silently ignored and safe defaults were not consistently enforced, leaving the unsafe filename handling path reachable whenever untrusted repositories were processed.

Potential impact

  • Malicious repositories may cause arbitrary files to be written or overwritten on the victim's Windows filesystem.
  • Attackers could place or modify scripts, configuration files, or executables that are later invoked, leading to remote code execution.
  • Compromise of application configuration used by build pipelines or developer tools.
  • Persistence or backdoor creation through modified startup files or service definitions.
  • Indirect supply-chain compromise if affected repositories are used in CI/CD, build, or packaging workflows.

General mitigation guidance

Effective mitigation centers on strict path normalization and platform-aware validation before writing repository contents to disk.

Recommended defensive patterns include:

  • Enforcing canonicalization of all paths derived from repository entries and rejecting any that escape the intended working directory.
  • Validating filenames against a denylist of reserved characters, device names, and path syntax that is specific to Windows filesystems.
  • Treating configuration-based safety toggles (such as NTFS/HFS protections) as secure-by-default, with explicit and clearly audited opt-outs only.
  • Isolating repository checkouts in dedicated, least-privileged environments so that even if a write escapes the project tree, it cannot impact sensitive system locations.
  • Decoupling execution paths from writable checkout locations (e.g., not executing directly from clone directories) to reduce the likelihood of file-write-to-RCE chains.

How teams detect issues like this

Detection efforts can focus on both code-level review and runtime behavior:

  • Static analysis and manual review to locate code that maps Git tree paths to filesystem paths, checking for robust normalization, platform-specific validation, and proper enforcement of safety options.
  • Rules that flag uses of raw path concatenation, unchecked handling of backslashes, device names, or relative path segments when processing repository entries on Windows.
  • Configuration audits to ensure safety-related options are correctly named, parsed, and enforced, with tests that intentionally misconfigure them to confirm behavior.
  • Runtime monitoring for unexpected writes outside of expected working directories during Git operations, using sandboxing logs or filesystem auditing where feasible.
  • Incorporating security-oriented test repositories with crafted filenames into CI to validate that path validation and NTFS protections behave as intended.

Sources

SourceLink
github.comgithub.com/jelmer/dulwich/commit/49eb56e51aad637fc23d54bf2a08cb42739b8290
github.comgithub.com/jelmer/dulwich/commit/57efc4aa1581e038915a0fd79365be53b150f4a9
github.comgithub.com/jelmer/dulwich/releases/tag/dulwich-1.2.5
github.comgithub.com/jelmer/dulwich/security/advisories/GHSA-897w-fcg9-f6xj

Frequently asked

questions

Yes, in the sense that an attacker can host or push a malicious Git repository that a victim later clones, fetches, or checks out with Dulwich on Windows, leading to arbitrary file writes and possible code execution without direct system access.

The attacker only needs the ability to supply or influence repository contents that a Dulwich-based client will process on Windows. They do not need local access to the victim machine, but exploitation relies on the victim performing Git operations on the malicious repository.

The safest pattern is to implement strict, platform-aware path normalization and validation before writing any file derived from external data, and to ensure protective configuration flags are correctly wired, secure by default, and covered by tests.

Future tools should treat all filenames from untrusted sources as hostile, normalize and validate them against a well-defined policy, enforce least privilege for filesystem writes, and integrate automated tests and code scanning focused on path handling, especially on platforms with complex filesystem semantics like Windows.

Find out what's already
exploitable in your codebase.