Get a Demo

Let's Patch It!

Book a short call with one our specialists, we'll walk you through how Endor Patches work, and ask you a few questions about your environment (like your primary programming languages and repository management). We'll also send you an email right after you fill out the form, feel free to reply with any questions you have in advance!

CVE

CVE-2026-22871

GuardDog Path Traversal Vulnerability Leads to Arbitrary File Overwrite and RCE
Back to all
CVE

CVE-2026-22871

GuardDog Path Traversal Vulnerability Leads to Arbitrary File Overwrite and RCE

Summary

path traversal vulnerability exists in GuardDog's safe_extract() function that allows malicious PyPI packages to write arbitrary files outside the intended extraction directory, leading to Arbitrary File Overwrite and Remote Code Execution on systems running GuardDog.

CWE: CWE-22 (Improper Limitation of a Pathname to a Restricted Directory)

Details

Vulnerable Code

File: guarddog/utils/archives.py

elif zipfile.is_zipfile(source_archive):
    with zipfile.ZipFile(source_archive, "r") as zip:
        for file in zip.namelist():
            # Note: zip.extract cleans up any malicious file name
            # such as directory traversal attempts This is not the
            # case of zipfile.extractall
            zip.extract(file, path=os.path.join(target_directory, file))  # ❌ VULNERABLE

Root Cause

The comment about zip.extract() fooled me at first :) then I noticed the os.path.join() call. 

The vulnerability stems from incorrect usage of Python's zipfile.ZipFile.extract() API:

  • The path parameter should be the target directory, not a full file path
  • extract() automatically appends the member name to the path
  • By passing os.path.join(target_directory, file), GuardDog causes the filename to be appended twice
  • This breaks zipfile's built-in path traversal sanitization

Attack Vector

  1. Attacker creates malicious wheel with path traversal filenames
  2. Uploads to PyPI or distributes directly
  3. Package scan: guarddog pypi scan malicious-pkg
  4. GuardDog downloads and extracts the package
  5. Malicious files written to arbitrary locations
  6. Code execution could be achieved

Impact

Impact depends on how GuardDog is running and under which environment.

Critical Scenarios

  1. Immediate Code Execution
  • Write to ~/.bashrc → executes on next shell
  • Write to ~/.profile → executes on login
  1. Persistent Backdoors
  • Write to ~/.ssh/authorized_keys → SSH access
  • Write to /etc/cron.d/malicious → scheduled execution (if root)
  • Write to systemd user services → persistent execution

and more...

Credits

Reported by: Charbel (dwbruijn)

Package Versions Affected

Package Version
patch Availability
No items found.

Automatically patch vulnerabilities without upgrading

Fix Without Upgrading
Detect compatible fix
Apply safe remediation
Fix with a single pull request

CVSS Version

Severity
Base Score
CVSS Version
Score Vector
C
H
U
8.7
-
4.0
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
C
H
U
0
-
C
H
U
9.8
-
3.1
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

Related Resources

No items found.

References

https://github.com/DataDog/guarddog/security/advisories/GHSA-xg9w-vg3g-6m68, https://nvd.nist.gov/vuln/detail/CVE-2026-22871, https://github.com/DataDog/guarddog/commit/9aa6a725b2c71d537d3c18d1c15621395ebb879c, https://github.com/DataDog/guarddog

Severity

9.8

CVSS Score
0
10

Basic Information

Ecosystem
Base CVSS
9.8
EPSS Probability
0.00553%
EPSS Percentile
0.6743%
Introduced Version
0,0.1.9,0.1.1
Fix Available
2.7.1

Fix Critical Vulnerabilities Instantly

Secure your app without upgrading.
Fix Without Upgrading