Summary
A path handling flaw in Outline's ZIP extraction logic can cause files to be written outside the intended sandbox directory when ZIP entries have very long nested paths.
By crafting ZIP entries that exceed the maximum path length, an attacker can cause extracted files to be created relative to the application's working directory, potentially overwriting or planting files in unintended locations.
Affected context
This issue appears in Outline deployments that:
- Allow users to import content via ZIP archives
- Rely on ZipHelper.extract to unpack uploaded ZIP files
- Run on systems where the joined extraction path can exceed the application's MAX_PATH_LENGTH (4096 bytes)
The vulnerability is tied to how long nested paths inside ZIP archives are normalized and truncated before creating files on disk, and how cleanup only targets the temporary extraction directory, not the broader working directory.
Exploit preconditions
- Attack surface: ZIP import functionality exposed through the Outline application (typically via web UI or API).
- Required access: Ability to upload or otherwise supply a ZIP archive to the Outline instance.
- Trigger point: Processing of a crafted ZIP archive where at least one entry's nested path is long enough that the full extraction path exceeds MAX_PATH_LENGTH (4096 bytes).
- Why exploitation is possible: When the computed filesystem path exceeds the length limit, the helper trimFileAndExt, which uses
path.basename, silently discards directory components and returns only a filename.fs.createWriteStreamthen creates the file relative to the process working directory instead of inside the extraction sandbox, and cleanup only removes the designated temporary directory, leaving the escaped file behind.
Why this happens
The core issue is an unsafe path normalization and truncation pattern in the ZIP extraction pipeline.
ZipHelper.extract computes a full path for each ZIP entry under a designated extraction directory and then passes that path through trimFileAndExt to enforce a maximum length constraint. trimFileAndExt uses path.basename on the full path when truncating, effectively stripping all directory components and returning only the filename when the length limit is exceeded.
This behavior maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, because the code assumes that any path manipulation still preserves the extraction sandbox prefix. In reality, truncation breaks this assumption, and the subsequent call to fs.createWriteStream operates on a bare filename relative to the process working directory, allowing file creation outside the intended restricted directory.
Potential impact
- Creation of attacker-controlled files in the Outline process working directory.
- Overwriting of existing files that share the truncated filename in the working directory (subject to filesystem permissions).
- Potential modification of application configuration, log, or auxiliary files if they are located in or under the working directory and share the targeted filename.
- Planting of files that may later be executed or served by other components, depending on deployment layout and server configuration.
- Persistence of extracted, attacker-controlled files beyond normal import cleanup, increasing the window of exposure.
General mitigation guidance
Mitigation should focus on enforcing strict directory confinement and safe path handling during archive extraction.
Useful defensive patterns include:
- Ensuring that any truncation or normalization logic operates only on filenames, not on full paths that include directory components, so that sandbox prefixes are never removed.
- Verifying after all path transformations that the final extraction path still resides within the intended extraction root (e.g., by resolving to an absolute path and checking the prefix).
- Rejecting ZIP entries with paths that exceed conservative length limits instead of silently truncating them.
- Treating all archive-supplied paths as untrusted and applying robust sanitization and validation rules, including checks against absolute paths, parent directory (
..) segments, and other path traversal tokens. - Running the extraction process with the least necessary filesystem privileges, ideally inside a dedicated directory isolated from configuration, executables, and other sensitive assets.
How teams detect issues like this
Detection efforts can focus on both code-level signals and runtime behavior:
- Static analysis & code review:
- Flag uses of generic filesystem APIs where user-controlled or archive-derived paths are passed to
fs.createWriteStream,fs.writeFile, or similar functions without explicit confinement checks. - Identify helper functions that manipulate full paths for length or formatting and then re-use them as filesystem paths, especially when they call
path.basenameor strip directory components. - Verify that every archive extraction path is validated post-normalization to ensure it remains within the intended sandbox directory.
- Policy and tooling:
- Add CI rules that disallow silent truncation of untrusted paths and require explicit handling (e.g., reject or log) when limits are reached.
- Employ security-focused linters or SAST tools configured with rules for path traversal and unsafe archive extraction patterns.
- Operational monitoring:
- Monitor for unexpected file creation or modification events in the Outline working directory and surrounding paths, especially following ZIP imports.
- Enable logging around archive extraction routines to capture anomalous or excessively long entry names for later review.

