Summary
Docmost's zip import feature in versions 0.21.0 through 0.23.x contains a path traversal flaw that allows files from a user-supplied ZIP archive to be written outside the intended import directory.
When exploited, an attacker-controlled ZIP can overwrite arbitrary files on the server's filesystem within the privileges of the Docmost process, potentially leading to data loss or further compromise.
Affected context
The vulnerability occurs in Docmost's server-side ZIP import logic located in apps/server/src/integrations/import/utils/file.utils.ts for versions 0.21.0 to before 0.24.0.
It arises when the application extracts user-provided ZIP archives without validating or sanitizing the embedded filenames or paths.
Any deployment that allows authenticated or unauthenticated users to upload/import ZIP files, and processes them using this utility, may be exposed depending on access controls and deployment configuration.
Exploit preconditions
- Attack surface: Server-side ZIP import endpoint or feature that processes user-supplied archives.
- Required access: Ability to upload or submit a ZIP file to the Docmost instance (typically via an import UI or API).
- Trigger point: Invoking the import functionality that unpacks ZIP entries using attacker-controlled filenames.
- Why exploitation is possible: The code uses entry names from the ZIP archive directly when writing files to disk, without normalizing or checking for path traversal sequences (e.g.,
../) or absolute paths. This allows files to be created or overwritten outside the intended import directory.
Why this happens
The core issue is a missing validation and normalization step for filenames extracted from ZIP archives, which maps directly to CWE-22: Path Traversal and the well-known ZipSlip pattern.
Instead of constraining extracted paths to a designated base directory, the implementation trusts the archive's internal paths, allowing special sequences and absolute paths to influence where files are written.
This insecure pattern lets attackers escape the intended extraction directory and write to arbitrary filesystem locations reachable by the Docmost server process.
Potential impact
- Overwriting application or configuration files that the Docmost process can write to.
- Placing malicious files (e.g., scripts, assets) in web-accessible directories, potentially enabling code execution depending on the stack and configuration.
- Corrupting or deleting documentation content and related data by overwriting important files.
- Tampering with logs, temporary files, or other resources to conceal malicious activity or degrade system reliability.
General mitigation guidance
Effective mitigation focuses on enforcing strict path controls and treating archive contents as untrusted input:
- Normalize and resolve each ZIP entry path against a predefined, application-controlled base directory before writing.
- Reject entries that attempt path traversal (e.g., contain
.., drive letters, or absolute paths) or resolve outside the intended import directory. - Use filesystem APIs or helper functions that safely join and canonicalize paths, then verify that the canonical path remains within the allowed root.
- Limit the Docmost process to least-privilege filesystem rights so that even if an issue occurs, reachable files are minimized.
- Consider enforcing size and file type constraints on imported content to reduce the attack surface and resource abuse.
How teams detect issues like this
Detection efforts can combine code-level analysis with runtime monitoring:
- Static analysis: Search for ZIP extraction code or filesystem writes that use archive entry names directly without normalization or boundary checks. Rules can flag any use of raw filenames derived from user-controlled ZIPs.
- Code review: During review of import or backup/restore features, look for missing validation of file paths, absence of checks for
..segments, and lack of canonical path verification against a base directory. - Policy enforcement: Introduce secure coding guidelines for archive processing and path handling, and enforce them via CI checks or pre-merge security gates.
- Runtime monitoring: Monitor logs and filesystem events for suspicious write patterns, such as unexpected file creation outside import directories during ZIP processing.

