/

CVE-2026-52726

Severity:

HIGH RISK

(7.5)

Path Traversal (CWE-22) in Dulwich Git Submodule Update

CVE-2026-52726

Deferred

Vulnerability type

Category:

Path Traversal / Unsafe Filesystem Write

CWE:

CWE-22

Impact:

Arbitrary Code Execution via Malicious Hook Injection

Severity:

HIGH RISK

(7.5)

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's submodule handling trusted attacker-controlled paths from .gitmodules without validating that they stayed within safe repository locations.

A malicious upstream repository can drop executable files into a victim's .git/hooks directory during submodule operations, leading to arbitrary code execution when hooks run.

Affected context

This vulnerability affects environments where Dulwich is used to clone or update Git repositories with submodules, especially via dulwich.porcelain.submodule_update or porcelain.clone(..., recurse_submodules=True).

Risk arises when the upstream repository is not fully trusted, or when repositories can be influenced by attackers (e.g., user-submitted or mirrored repositories).

The issue manifests when submodule paths from .gitmodules are accepted as-is and materialized into the filesystem, including within the parent repository's .git directory.

Exploit preconditions

  • Attack surface: Git repositories processed by Dulwich that contain submodules.
  • Required access: Ability to control or modify the upstream repository contents, including .gitmodules and the tree entries that correspond to submodules.
  • Trigger point: Execution of dulwich.porcelain.submodule_update or porcelain.clone(..., recurse_submodules=True) against the crafted repository.
  • Why exploitation is possible: Dulwich's submodule porcelain accepts submodule path values from .gitmodules without enforcing that they remain outside the .git directory or other sensitive internal paths, allowing attacker-controlled content to be written into .git/hooks and similar locations.

Why this happens

The core issue is a lack of path validation and normalization when materializing submodule paths specified in the .gitmodules file.

Dulwich's implementation of submodule update logic treats these paths as trustworthy and directly maps them to filesystem locations within the parent repository, including its .git directory.

This behavior aligns with CWE-22: Improper Limitation of a Pathname to a Restricted Directory, where user-controlled or remote-controlled path components are not constrained to a safe directory, enabling writes into sensitive internal paths such as .git/hooks.

Potential impact

  • Attacker-controlled executables can be written into .git/hooks/, preserving executable permissions.
  • Arbitrary code can be executed when Git or Dulwich commands trigger the compromised hooks.
  • Local developer or CI environment compromise through execution of malicious hooks during clone, fetch, commit, or other hook-invoking operations.
  • Potential pivot into broader build or deployment infrastructure if compromised repositories are used in automated pipelines.

General mitigation guidance

Mitigation typically focuses on constraining where submodule paths are allowed to resolve and treating repository metadata as untrusted input.

Useful defensive patterns include:

  • Enforcing path normalization and explicit checks that submodule paths cannot point into .git or other internal control directories.
  • Rejecting any submodule configuration whose paths are absolute, contain .. segments, or otherwise escape the repository working tree.
  • Treating upstream repositories, especially from external or user-controlled sources, as untrusted and applying additional validation or policy checks before materializing submodules.
  • Running repository operations under least-privilege accounts and separating build/CI agents from sensitive host-level privileges to limit the blast radius of malicious hooks.
  • Where feasible, disabling automatic hook execution in high-risk automation contexts or enforcing a whitelist of allowed hooks.

How teams detect issues like this

Detection efforts can focus on both source-level patterns and repository hygiene:

  • Static analysis or code review to identify filesystem write operations that rely on unvalidated paths taken from .gitmodules or other repository metadata.
  • Repository scanning to flag .gitmodules entries whose path points into .git, contains traversal sequences, or otherwise targets internal directories.
  • CI policies that reject or quarantine repositories where submodule paths do not remain within the main working tree.
  • Monitoring of hook directories for unexpected or newly introduced executable files, especially following clone or submodule update operations.
  • Integrating automated review tools into development workflows to highlight missing path normalization and checks around submodule handling code.

Sources

SourceLink
github.comgithub.com/jelmer/dulwich/releases/tag/dulwich-1.2.5
github.comgithub.com/jelmer/dulwich/security/advisories/GHSA-gfhv-vqv2-4544

Frequently asked

questions

It can be exploited remotely in scenarios where a victim clones or updates a repository controlled by an attacker, such as a public or user-submitted repository. The attacker does not need local access to the victim's machine, but the victim must perform Dulwich-based operations on the crafted repository.

The attacker needs control over, or the ability to influence, the upstream Git repository content, specifically .gitmodules and the associated submodule tree entries. No direct shell or filesystem access to the victim's host is required.

The safest pattern is to strictly validate and normalize all submodule paths before creating directories or writing files, rejecting any path that escapes the repository working tree or targets internal directories like .git. Treat .gitmodules and similar metadata as untrusted and enforce hard-coded rules about where submodules can be placed.

Design filesystem-related features assuming all path components from repositories or users are untrusted. Implement centralized path validation helpers, add tests for edge cases such as .git, .., and absolute paths, and enforce security checks in code review and CI so that new path-based features must pass these validation rules.

Find out what's already
exploitable in your codebase.