Summary
The extract-zip library fails to validate symlink targets when extracting archives, allowing links to point outside the intended extraction directory.
If a malicious ZIP includes symlinks with traversal paths (e.g., "../../../../etc/passwd"), applications using extract-zip may inadvertently enable arbitrary file read or write operations depending on their usage context.
Affected context
This vulnerability occurs in applications that rely on extract-zip to unpack user-provided or untrusted ZIP archives without additional path or symlink validation.
It is most relevant when extracted content is later read, served, or overwritten by the application or other system components under the assumption that all files and links remain contained within a dedicated extraction directory.
The risk increases when the process has access to sensitive filesystem locations or runs with elevated privileges.
Exploit preconditions
- Attack surface: ZIP archive ingestion paths (file upload endpoints, package importers, content processing pipelines, or any workflow that unpacks ZIP files using extract-zip).
- Required access: Ability to supply or control a ZIP file that will be processed by an extract-zip-based workflow, typically through an upload, sync, or import mechanism.
- Trigger point: Archive extraction using extract-zip, where the library creates filesystem entries, including symlinks, directly based on data inside the ZIP.
- Why exploitation is possible: Symlink targets within the archive are not normalized or constrained to the extraction root. As a result, path traversal sequences and absolute paths can produce symlinks pointing to arbitrary locations on the host filesystem, enabling indirect access when those links are later followed.
Why this happens
At its core, this issue stems from improper restriction of file paths during archive extraction, aligning with CWE-22 (Improper Limitation of a Pathname to a Restricted Directory) and CWE-61 (Improper Restriction of Symlink Following).
The extract-zip library trusts symlink entries embedded in ZIP files and creates them without validating or resolving their target paths against the intended extraction root.
This insecure pattern allows relative path traversal (e.g., "../" sequences) or crafted absolute paths to escape the designated directory boundary.
When application logic subsequently reads from or writes to these symlinks, it can unintentionally operate on sensitive or unintended files elsewhere in the filesystem.
Potential impact
- An attacker may cause the application to read sensitive files through symlinks pointing to locations such as configuration files, credentials stores, or system data.
- The application could overwrite or modify arbitrary files when writing to paths that resolve through malicious symlinks.
- Local privilege escalation may occur if the vulnerable process runs with higher privileges and is tricked into altering security-critical files (e.g., logs, configuration, or service scripts).
- Data integrity issues can arise if application- or system-owned files are unexpectedly replaced or corrupted via redirected writes.
- In multi-tenant environments, one tenant could potentially access or interfere with another tenant's data by abusing shared extraction paths.
General mitigation guidance
Effective mitigation focuses on enforcing strict directory boundaries and treating archive contents as untrusted until validated.
Common defensive patterns include:
- Normalizing and validating all paths from ZIP entries (including symlink targets) to ensure they remain within a configurable extraction root, rejecting or sanitizing entries that traverse outside.
- Disabling or filtering symlink extraction entirely when not strictly required, or replacing symlinks with safe metadata representations rather than filesystem links.
- Implementing an allowlist-based extraction policy that only permits expected file types and locations, and skips unexpected links or special filesystem objects.
- Running archive extraction under least-privilege accounts with limited filesystem access to reduce the impact of any escaped paths.
- Isolating extraction into dedicated, sandboxed directories or containers and treating extracted artifacts as untrusted until additional validation logic completes.
How teams detect issues like this
Detection typically combines code-level review with operational safeguards:
- Static analysis or linters can flag uses of archive libraries that create symlinks or write files without validating normalized paths against an expected root directory.
- Code reviews should look for patterns where filesystem paths derived from ZIP entries are used directly, especially where "../" sequences or absolute paths are not explicitly handled.
- Security policies may require that archive extraction utilities enforce path canonicalization and block symlink creation unless explicitly justified.
- Runtime monitoring can track file system changes during extraction workflows, alerting when processes create symlinks or write outside designated extraction directories.
- Automated dependency scanning tools can highlight known archive-handling vulnerabilities and prompt inspection of how libraries like extract-zip are integrated.

