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

