/

CVE-2026-32731

Severity:

CRITICAL RISK

(9.9)

Path Traversal / Zip Slip in ApostropheCMS Import-Export

CVE-2026-32731

Analyzed

Vulnerability type

Category:

Path Traversal / Zip Slip

CWE:

CWE-22

Impact:

Arbitrary File Write on Server Filesystem

Severity:

CRITICAL RISK

(9.9)

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

A path traversal vulnerability in the @apostrophecms/import-export module allows archive entries to escape the intended extraction directory during .tar.gz imports.

When a privileged CMS user uploads a crafted archive, attacker-controlled files can be written to arbitrary locations on the server filesystem reachable by the Node.js process.

Affected context

The issue arises in ApostropheCMS deployments that use the @apostrophecms/import-export module to handle .tar.gz imports through the CMS UI.

The vulnerable behavior occurs when archive entry names are directly joined with the configured export path using path.join(exportPath, header.name) without any normalization or traversal checks.

In such configurations, any user who has been granted Global Content Modify permission and can access the import interface may supply crafted archive entries whose paths resolve outside the expected extraction directory.

Exploit preconditions

  • Attack surface: ApostropheCMS import/export functionality exposed via the standard CMS import UI.
  • Required access: Valid authenticated account with Global Content Modify permission (commonly assigned to editors or site managers).
  • Trigger point: Uploading and importing a crafted .tar.gz file containing entries with traversal segments (e.g., ../) in their names.
  • Why exploitation is possible: The extraction logic uses fs.createWriteStream(path.join(exportPath, header.name)) without canonical-path validation or rejection of traversal sequences, allowing archive entries to resolve to paths outside the intended export directory.

Why this happens

The core bug is a classic path traversal (Zip Slip) condition where user-controlled archive entry names are trusted as filesystem paths.

Instead of resolving and validating the canonical path, the code simply concatenates exportPath and header.name with path.join(), which does not sanitize .. segments or absolute paths.

This maps directly to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, because the implementation fails to enforce that all extracted files remain within a designated base directory before opening write streams.

Potential impact

  • Attacker-controlled files may be written to arbitrary locations accessible to the Node.js process.
  • Overwriting of existing application files, configuration, or content stores.
  • Planting of malicious server-side scripts or backdoors where a runtime or admin later executes or loads them.
  • Tampering with logs, data files, or other assets to aid further compromise or concealment.
  • Escalation of impact if the Node.js process has write access to sensitive system directories or shared volumes.

General mitigation guidance

Robust mitigation centers on strictly confining archive extraction to a known-safe directory and treating entry names as untrusted input.

Common defensive patterns include:

  • Normalizing each archive entry path (e.g., resolving . and ..) and computing its canonical form before writing to disk.
  • Verifying that the canonical extraction path starts with the intended base directory; reject entries that escape this boundary.
  • Rejecting or sanitizing absolute paths, drive roots, and any entry names containing traversal segments.
  • Extracting only into dedicated, least-privilege directories with minimized filesystem access for the process.
  • Implementing a clear allowlist of acceptable file types and locations where imported content may be written.

These patterns ensure that even if an attacker controls the archive, files cannot be written outside the designated import area.

How teams detect issues like this

Effective detection typically combines code-centric and operational approaches:

  • Static analysis: Define rules to flag uses of fs.createWriteStream, fs.writeFile, or similar APIs where paths are constructed from untrusted input (such as archive entry names) without canonicalization and boundary checks.
  • Code review signals: Look for archive extraction code that uses path.join() directly on user-controlled names, lacks .. and absolute path validation, or omits checks that the final path resides under a specific base directory.
  • Security testing: Incorporate Zip Slip test archives into routine QA and security testing to verify that extraction logic rejects traversal entries.
  • Automated tooling: Integrate SAST or dependency scanning tools that recognize common Zip Slip patterns and flag risky extraction implementations in CI pipelines.

Sources

SourceLink
github.comgithub.com/apostrophecms/apostrophe/security/advisories/GHSA-mwxc-m426-3f78

Frequently asked

questions

Yes, if the ApostropheCMS instance exposes its admin interface over the network and an attacker can obtain an account with Global Content Modify permission. The attack is carried out by uploading a crafted .tar.gz via the import UI, not via unauthenticated HTTP endpoints.

The attacker needs authenticated access with at least Global Content Modify permission, which is often granted to content editors or site managers. No additional system-level access is required beyond that application role.

Always normalize and validate the full filesystem path for each archive entry before writing, ensuring it remains strictly within a designated extraction directory. Reject entries that resolve outside that directory, contain traversal segments, or use absolute paths, and confine extraction to a minimally privileged location.

Treat all filenames and paths derived from user-controlled data as untrusted; apply canonical-path checks against a fixed base directory, use allowlists of permitted destinations, and incorporate security review and automated testing specifically targeting Zip Slip and path traversal scenarios whenever adding import/export or file upload functionality.

Find out what's already
exploitable in your codebase.