CVE-2026-22871: Guarddog Remote Code Execution Vulnerability

HIGH
Advisory Identifier: GHSA-xg9w-vg3g-6m68
CWE-22
Published
Advisory Summary

CVE-2026-22871 is a HIGH remote code execution vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Guarddog libraries in the PyPI ecosystem. The issue involves guarddog path traversal vulnerability leads to arbitrary file overwrite and rce. Remediation is available by upgrading affected packages to version 2.7.1.

CVE-2026-22871 at a Glance

CVE Identifier CVE-2026-22871
GHSA Identifier GHSA-xg9w-vg3g-6m68
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product Guarddog
Package Ecosystem PyPI
Published Date
Last Updated

How to Fix CVE-2026-22871

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

guarddog fixed: 2.7.1
pip install guarddog>=2.7.1
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 guarddog

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-22871, inspect your installed packages using pip:

pip show guarddog

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

Note: The pip show guarddog 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 Guarddog, 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

## Summary A **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` ```python 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 2. **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)

CVE-2026-22871 Affected Guarddog Versions

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

References

Frequently Asked Questions

What is CVE-2026-22871?
CVE-2026-22871 is a security vulnerability in Guarddog involving GuardDog Path Traversal Vulnerability Leads to Arbitrary File Overwrite and RCE under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Guarddog versions are affected?
Affected versions include releases prior to 2.7.1 across affected packages: guarddog.
What version fixes CVE-2026-22871?
Upgrading to 2.7.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is guarddog affected?
Yes, guarddog is affected in releases prior to 2.7.1. Upgrade your dependency to 2.7.1 or later.
What CWE is associated with CVE-2026-22871?
CVE-2026-22871 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 CVE-2026-22871?
Run the dependency tree command: 'pip show guarddog'. 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-xg9w-vg3g-6m68",
  "modified" : "2026-01-13T21:54:49Z",
  "published" : "2026-01-13T21:54:49Z",
  "aliases" : [ "CVE-2026-22871" ],
  "summary" : "GuardDog Path Traversal Vulnerability Leads to Arbitrary File Overwrite and RCE",
  "details" : "## Summary\n\nA **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.\n\n**CWE:** CWE-22 (Improper Limitation of a Pathname to a Restricted Directory)\n\n## Details\n\n### Vulnerable Code\n\n**File:** `guarddog/utils/archives.py`\n\n```python\nelif zipfile.is_zipfile(source_archive):\n    with zipfile.ZipFile(source_archive, \"r\") as zip:\n        for file in zip.namelist():\n            # Note: zip.extract cleans up any malicious file name\n            # such as directory traversal attempts This is not the\n            # case of zipfile.extractall\n            zip.extract(file, path=os.path.join(target_directory, file))  # ❌ VULNERABLE\n```\n\n### Root Cause\n\nThe comment about `zip.extract()` fooled me at first :) then I noticed the `os.path.join()` call. \nThe vulnerability stems from **incorrect usage of Python's `zipfile.ZipFile.extract()` API**:\n\n- The `path` parameter should be the **target directory**, not a full file path\n- `extract()` automatically appends the member name to the path\n- By passing `os.path.join(target_directory, file)`, GuardDog causes the filename to be appended **twice**\n- This breaks zipfile's built-in path traversal sanitization\n\n### Attack Vector\n\n1. Attacker creates malicious wheel with path traversal filenames\n2. Uploads to PyPI or distributes directly\n3. Package scan: `guarddog pypi scan malicious-pkg`\n4. GuardDog downloads and extracts the package\n5. Malicious files written to arbitrary locations\n6. Code execution could be achieved\n\n## Impact\n\nImpact depends on how GuardDog is running and under which environment.\n\n### Critical Scenarios\n\n1. **Immediate Code Execution**\n   - Write to `~/.bashrc` → executes on next shell\n   - Write to `~/.profile` → executes on login\n\n2. **Persistent Backdoors**\n   - Write to `~/.ssh/authorized_keys` → SSH access\n   - Write to `/etc/cron.d/malicious` → scheduled execution (if root)\n   - Write to systemd user services → persistent execution\n\nand more...\n\n## Credits\n\n**Reported by:** Charbel (dwbruijn)",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "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"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "guarddog"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.7.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/DataDog/guarddog/security/advisories/GHSA-xg9w-vg3g-6m68"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-22871"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/DataDog/guarddog/commit/9aa6a725b2c71d537d3c18d1c15621395ebb879c"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/DataDog/guarddog"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-01-13T21:54:49Z",
    "nvd_published_at" : "2026-01-13T21:15:55Z"
  }
}