GitPython: Incomplete unsafe_git_archive_options denylist omits --add-file / --add-virtual-file, enabling arbitrary file read via Repo.archive()
GitPython's Repo.archive() method uses a denylist to block unsafe git archive options, but this denylist is incomplete. Specifically, the options --add-file and --add-virtual-file, which allow reading arbitrary files from the filesystem and injecting arbitrary content into archives, are not blocked. This enables an attacker who can control the options passed to Repo.archive() to read arbitrary files with the privileges of the running process. The vulnerability does not allow code execution but can lead to sensitive file disclosure. A patch is available that extends the denylist to cover these options or implements a safer allowlist approach.
AI Analysis
Technical Summary
The vulnerability in GitPython arises because the unsafe_git_archive_options denylist consulted by Repo.archive() omits the --add-file and --add-virtual-file options. While the denylist blocks options that allow writing to arbitrary filesystem paths or executing commands, it does not block these two options that allow reading arbitrary files and injecting arbitrary content into the archive. This gap permits an attacker controlling the options passed to Repo.archive() to include arbitrary files from the filesystem in the generated archive, leading to arbitrary file read at the process privilege level. The issue was confirmed with a proof-of-concept that reads an out-of-tree file and extracts its contents from the archive. The recommended remediation is to either implement a strict allowlist of safe options or extend the denylist to include these options, consistent with the existing rationale for blocking options that take filesystem paths or URLs.
Potential Impact
An attacker able to influence the options passed to Repo.archive() can read arbitrary files on the filesystem with the privileges of the GitPython process. This can lead to disclosure of sensitive information. The vulnerability does not enable code execution or denial of service. The impact is limited to confidentiality loss via arbitrary file read.
Mitigation Recommendations
A patch is available for this vulnerability. The vendor or maintainers have extended the denylist to include --add-file and --add-virtual-file options or recommend implementing a strict allowlist of safe options for Repo.archive(). Users should upgrade GitPython to version 3.1.57 or later where this issue is fixed. If upgrading is not immediately possible, avoid passing user-controlled options to Repo.archive() or implement custom validation to block these unsafe options.
GitPython: Incomplete unsafe_git_archive_options denylist omits --add-file / --add-virtual-file, enabling arbitrary file read via Repo.archive()
Description
GitPython's Repo.archive() method uses a denylist to block unsafe git archive options, but this denylist is incomplete. Specifically, the options --add-file and --add-virtual-file, which allow reading arbitrary files from the filesystem and injecting arbitrary content into archives, are not blocked. This enables an attacker who can control the options passed to Repo.archive() to read arbitrary files with the privileges of the running process. The vulnerability does not allow code execution but can lead to sensitive file disclosure. A patch is available that extends the denylist to cover these options or implements a safer allowlist approach.
CVSS v3.1
Score 6.5medium
Affected software
Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
The vulnerability in GitPython arises because the unsafe_git_archive_options denylist consulted by Repo.archive() omits the --add-file and --add-virtual-file options. While the denylist blocks options that allow writing to arbitrary filesystem paths or executing commands, it does not block these two options that allow reading arbitrary files and injecting arbitrary content into the archive. This gap permits an attacker controlling the options passed to Repo.archive() to include arbitrary files from the filesystem in the generated archive, leading to arbitrary file read at the process privilege level. The issue was confirmed with a proof-of-concept that reads an out-of-tree file and extracts its contents from the archive. The recommended remediation is to either implement a strict allowlist of safe options or extend the denylist to include these options, consistent with the existing rationale for blocking options that take filesystem paths or URLs.
Potential Impact
An attacker able to influence the options passed to Repo.archive() can read arbitrary files on the filesystem with the privileges of the GitPython process. This can lead to disclosure of sensitive information. The vulnerability does not enable code execution or denial of service. The impact is limited to confidentiality loss via arbitrary file read.
Mitigation Recommendations
A patch is available for this vulnerability. The vendor or maintainers have extended the denylist to include --add-file and --add-virtual-file options or recommend implementing a strict allowlist of safe options for Repo.archive(). Users should upgrade GitPython to version 3.1.57 or later where this issue is fixed. If upgrading is not immediately possible, avoid passing user-controlled options to Repo.archive() or implement custom validation to block these unsafe options.
Technical Details
- Gcve Source
- db.gcve.eu
- Osv Id
- GHSA-539m-9xh6-q6rr
- Osv Schema Version
- 1.4.0
- Aliases
- []
- Ecosystems
- ["PyPI"]
- Database Specific Severity
- MODERATE
- Cvss Version
- 3.1
Threat ID: 6a710652bf32cb7a34392e6b
Added to database: 08/03/2026, 21:21:22 UTC
Last enriched: 08/03/2026, 21:24:08 UTC
Last updated: 08/04/2026, 00:00:13 UTC
Views: 3
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.