CVE-2026-40258: gramps-webapi Path Traversal Vulnerability

CRITICAL
Advisory Identifier: GHSA-m5gr-86j6-99jp
CVSS 9.1
CWE-22
Published
Advisory Summary

CVE-2026-40258 is a CRITICAL (CVSS 9.1) path traversal vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting gramps-webapi libraries in the PyPI ecosystem. The issue involves zip slip path traversal in media archive import. Remediation is available by upgrading affected packages to version 3.11.1.

CVE-2026-40258 at a Glance

CVE Identifier CVE-2026-40258
GHSA Identifier GHSA-m5gr-86j6-99jp
Severity CRITICAL
CVSS v3.1 Base Score 9.1
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product gramps-webapi
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 9.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required High (PR:H)
User Interaction None (UI:N)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2026-40258

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

gramps-webapi fixed: 3.11.1
pip install gramps-webapi>=3.11.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 gramps-webapi

How to Check if You Are Affected

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

pip show gramps-webapi

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

Note: The pip show gramps-webapi 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 gramps-webapi, 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 (Zip Slip) exists in the media archive import feature. An authenticated user with owner-level privileges can craft a malicious ZIP file with directory-traversal filenames to write arbitrary files outside the intended temporary extraction directory on the server's local filesystem. ## Details When importing media archives as ZIP file, `MediaImporter._check_disk_space_and_extract()` in `gramps_webapi/api/media_importer.py` called `zipfile.extractall()` without validating ZIP entry names. Python's `zipfile` module does not sanitize entry names containing `../` sequences, allowing extraction to paths outside the target directory. Only users with **owner permission** can upload media ZIP archives, so the biggest risk is for multi-tree deployments, where tree owners are distinct from server administrators. For multi-tree deployments, the impact depends on deployment configuration. Assuming the standard docker-based deployment is used: - **SQLite family tree + local media**: An attacker can overwrite another tree's database file or media files, leading to cross-tree data corruption or replacement. - **Postgres family tree + S3 media**: No persistent tree data is stored on the local filesystem, so cross-tree impact is eliminated. The remaining risk is overwriting volume-mounted files such as the application config file. - **Postgres family tree + S3 media + environment-variable-only config**: No persistent files of value are present on the local filesystem. Impact is limited to writes to ephemeral container storage, which are lost on woker restart. ## Fix ZIP entry names are now validated against the resolved real path of the temporary directory before extraction. Any entry whose resolved path falls outside the temporary directory raises an error and aborts the import.

CVE-2026-40258 Affected gramps-webapi Versions

1 component(s)
Fixed Versions:
3.11.1
Product / Package Ecosystem Affected Versions Fixed Version
gramps-webapi
PyPI
≥ 1.6.0
< 3.11.1
3.11.1

References

Frequently Asked Questions

What is CVE-2026-40258?
CVE-2026-40258 is a security vulnerability in gramps-webapi involving Zip Slip Path Traversal in Media Archive Import under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which gramps-webapi versions are affected?
Affected versions include releases prior to 3.11.1 across affected packages: gramps-webapi.
What version fixes CVE-2026-40258?
Upgrading to 3.11.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is gramps-webapi affected?
Yes, gramps-webapi is affected in releases prior to 3.11.1. Upgrade your dependency to 3.11.1 or later.
What is the CVSS score of CVE-2026-40258?
CVE-2026-40258 has a CVSS v3.1 base score of 9.1 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H.
What CWE is associated with CVE-2026-40258?
CVE-2026-40258 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-40258?
Run the dependency tree command: 'pip show gramps-webapi'. 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-m5gr-86j6-99jp",
  "modified" : "2026-04-24T20:49:27Z",
  "published" : "2026-04-10T21:00:09Z",
  "aliases" : [ "CVE-2026-40258" ],
  "summary" : "gramps-webapi: Zip Slip Path Traversal in Media Archive Import",
  "details" : "## Summary\n\nA path traversal vulnerability (Zip Slip) exists in the media archive import feature. An authenticated user with owner-level privileges can craft a malicious ZIP file with directory-traversal filenames to write arbitrary files outside the intended temporary extraction directory on the server's local filesystem.\n\n## Details\n\nWhen importing media archives as ZIP file, `MediaImporter._check_disk_space_and_extract()` in `gramps_webapi/api/media_importer.py` called `zipfile.extractall()` without validating ZIP entry names. Python's `zipfile` module does not sanitize entry names containing `../` sequences, allowing extraction to paths outside the target directory.\n\nOnly users with **owner permission** can upload media ZIP archives, so the biggest risk is for multi-tree deployments, where tree owners are distinct from server administrators.\n\nFor multi-tree deployments, the impact depends on deployment configuration. Assuming the standard docker-based deployment is used:\n\n- **SQLite family tree + local media**: An attacker can overwrite another tree's database file or media files, leading to cross-tree data corruption or replacement.\n- **Postgres family tree + S3 media**: No persistent tree data is stored on the local filesystem,  so cross-tree impact is eliminated. The remaining risk is overwriting volume-mounted files such as the application config file.\n- **Postgres family tree + S3 media + environment-variable-only config**: No persistent files of  value are present on the local filesystem. Impact is limited to writes to ephemeral container storage, which are lost on woker restart.\n\n## Fix\n\nZIP entry names are now validated against the resolved real path of the temporary directory before extraction. Any entry whose resolved path falls outside the temporary directory raises an error and aborts the import.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "gramps-webapi"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.6.0"
      }, {
        "fixed" : "3.11.1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 3.11.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/gramps-project/gramps-web-api/security/advisories/GHSA-m5gr-86j6-99jp"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-40258"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gramps-project/gramps-web-api/commit/3ed4342711e3ec849552df09b1fe2fbf2ca5c29a"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/gramps-project/gramps-web-api"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gramps-project/gramps-web-api/releases/tag/v3.11.1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-04-10T21:00:09Z",
    "nvd_published_at" : "2026-04-17T22:16:32Z"
  }
}