---
id: "CVE-2026-40258"
kind: "vulnerability"
aliases: ["CVE-2026-40258", "GHSA-m5gr-86j6-99jp"]
title: "gramps-webapi: Zip Slip Path Traversal in Media Archive Import"
severity: "critical"
cvss: 9.1
epss: 0.00401
exploited: false
status: "open"
category: "package"
products: [{"name": "gramps-webapi", "fixed": ["3.11.1"], "affected": ">= 1.6.0, <= 3.11.0", "ecosystem": "pypi"}]
ecosystems: ["pypi"]
tags: ["cwe-22", "gramps-web", "multi-tree", "package", "python", "self-hosted"]
not_affected_if: ["env-only-config", "postgres-with-s3-media", "single-tree"]
published_at: "2026-04-10T21:00:09+00:00"
first_seen_at: "2026-10-27T16:35:55+00:00"
updated_at: "2026-10-27T16:38:03+00:00"
sources: [{"source": "ghsa", "url": "https://github.com/advisories/GHSA-m5gr-86j6-99jp", "first_seen_at": "2026-10-27T16:35:55+00:00"}, {"source": "nvd", "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-40258", "first_seen_at": "2026-10-27T17:03:04+00:00"}]
---

# gramps-webapi: Zip Slip Path Traversal in Media Archive Import

Gramps Web API extracts uploaded media ZIP archives without checking entry names, so a ZIP with ../ paths writes files outside the extraction directory. An owner-level user can overwrite other trees' database or media files on local-storage deployments.

_Summary, check and fix written by a model from the sources; labelled as such._

## Affected

- pypi:gramps-webapi affected >= 1.6.0, <= 3.11.0 fixed 3.11.1

## How to check

- Run `pip show gramps-webapi` and confirm the installed version is between `1.6.0` and `3.11.0`
- Check whether multiple family trees are hosted on one instance with SQLite trees and local media storage

## Fix

- Upgrade `gramps-webapi` to `3.11.1`
- Until upgraded, restrict media ZIP import to trusted users or disable owner uploads on shared instances

## Timeline

- 2026-10-27T16:35:55+00:00 ghsa https://github.com/advisories/GHSA-m5gr-86j6-99jp
- 2026-10-27T17:03:04+00:00 nvd https://nvd.nist.gov/vuln/detail/CVE-2026-40258

## From the sources

## 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.

---

_Free to read at a human pace. An API with keys and an MCP server are in preparation; early access: hello@infrastack.ai_
