/

CVE-2026-40258

Severity:

CRITICAL RISK

(9.1)

Path Traversal / Zip Slip in Gramps Web Media Archive Import

CVE-2026-40258

Deferred

Vulnerability type

Category:

Path Traversal / Zip Slip

CWE:

CWE-22

Impact:

Arbitrary File Write on Server Filesystem (Path Traversal via ZIP Extraction)

Severity:

CRITICAL RISK

(9.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Gramps Web API versions 1.6.0 through 3.11.0 contain a path traversal ("Zip Slip") vulnerability in the media archive import feature that allows ZIP entries with crafted directory traversal paths to escape the intended extraction directory.

An authenticated user with owner-level privileges can use a malicious ZIP file to write arbitrary files on the server's local filesystem outside the temporary directory, potentially overwriting sensitive files or planting malicious content.

Affected context

The vulnerability appears in deployments of the Gramps Web API that enable the media archive import functionality and accept ZIP uploads from authenticated users.

It specifically impacts the logic that extracts user-supplied ZIP archives into a temporary directory on the server, without adequately validating that each extracted entry remains within that directory.

The risk is most relevant where the web API runs with filesystem permissions that allow writes to directories beyond the temporary extraction path.

Exploit preconditions

  • Attack surface: Media archive import endpoint that accepts ZIP files.
  • Required access: Authenticated access with owner-level privileges to the affected Gramps Web API instance.
  • Trigger point: Submission of a crafted ZIP file containing entries whose filenames use directory traversal sequences (for example, attempting to navigate out of the target directory).
  • Why exploitation is possible: The extraction routine trusts the entry names inside the ZIP and constructs output paths directly (or with insufficient checks), allowing paths that resolve outside the intended temporary directory to be written to disk.

Why this happens

The core issue stems from insufficient validation of filesystem paths derived from untrusted ZIP entry names before writing them to disk.

When the import feature iterates over ZIP entries, it uses the entry's path (potentially containing sequences that traverse parent directories) to build the destination path and perform file writes.

Without normalizing and comparing the resolved absolute path against the intended temporary extraction directory, the code effectively allows user-controlled path components to escape the target directory.

This aligns with CWE-22: Improper Limitation of a Pathname to a Restricted Directory, in the specific "Zip Slip" pattern where archive extraction code fails to constrain the effective output location of each entry.

Potential impact

  • Arbitrary file creation in directories writable by the Gramps Web API process.
  • Overwriting existing application or configuration files that the service user can access.
  • Planting malicious web-accessible content or scripts (depending on deployment) that could be used in follow-on attacks.
  • Tampering with genealogical data files or related media assets, potentially causing data loss or corruption.
  • Facilitating privilege escalation or lateral movement if sensitive system files or service configuration files are overwritten.

General mitigation guidance

Effective mitigation focuses on strictly constraining where archive entries may be written and reducing the trust placed in user-supplied filenames:

  • Normalize and resolve each ZIP entry's target path to an absolute path and verify that it remains within the intended extraction directory before writing.
  • Reject or error on any ZIP entry whose resolved path attempts to traverse outside the designated directory, aborting the import operation if necessary.
  • Treat filenames and paths from user-controlled archives as untrusted input, applying consistent canonicalization and containment checks.
  • Run the Gramps Web API under a dedicated OS account with minimal filesystem privileges, restricting write access to only those directories required for operation.
  • Use separate, tightly scoped directories for temporary extraction and subsequent processing, and avoid running other sensitive services from locations writable by the API process.

How teams detect issues like this

Detection approaches can combine code-level and operational techniques:

  • Static analysis: Flag archive extraction code that concatenates user-controlled ZIP entry names with filesystem paths without canonicalization and containment checks; search for use of ZIP libraries where entry names are trusted directly.
  • Code review: Look for patterns where extract or equivalent APIs are used without validating output paths, or where ../ and absolute path handling are not explicitly addressed in ZIP processing logic.
  • Runtime monitoring: Monitor filesystem activity from the Gramps Web API process for unexpected writes outside designated media or temporary directories, especially immediately following ZIP imports.
  • Policy enforcement: Incorporate secure archive handling guidelines into development standards and enforce them via pre-commit hooks, CI checks, or automated review tools supporting path-traversal and Zip Slip patterns.

Sources

SourceLink
github.comgithub.com/gramps-project/gramps-web-api/commit/3ed4342711e3ec849552df09b1fe2fbf2ca5c29a
github.comgithub.com/gramps-project/gramps-web-api/releases/tag/v3.11.1
github.comgithub.com/gramps-project/gramps-web-api/security/advisories/GHSA-m5gr-86j6-99jp

Frequently asked

questions

Yes, but only through authenticated access. An attacker must be able to reach the Gramps Web API and successfully authenticate with owner-level privileges to upload a malicious ZIP file.

The issue requires an authenticated user with owner-level privileges on the Gramps Web instance. Anonymous or lower-privileged users, under normal configuration, cannot trigger the vulnerable media archive import path.

The robust fix is to compute the canonical absolute path of each ZIP entry's intended destination and verify that it resides within the designated extraction directory before writing. Any entry whose resolved path falls outside that directory should cause an error and abort the import, rather than being silently adjusted or partially extracted.

Treat all file and path data derived from users or external archives as untrusted. Always normalize paths, enforce containment checks against known-safe directories, and enforce least-privilege filesystem permissions for the service. Incorporating explicit "no directory traversal" tests into unit and integration test suites for file upload and extraction workflows can help catch regressions early.

Find out what's already
exploitable in your codebase.