Summary
A Zip Slip style path traversal vulnerability in Zed's extension archive extraction allows crafted ZIP files to write files outside the intended sandbox directory.
A malicious or compromised extension that can supply a ZIP archive may escape its designated directory and overwrite arbitrary files accessible to the Zed process.
Affected context
The vulnerability occurs in Zed's extension handling pipeline, specifically when downloading and extracting extension ZIP archives using the extract_zip() function in crates/util/src/archive.rs.
It applies when Zed processes ZIP files that are not fully trusted and extracts them into a sandbox directory without validating entry paths for traversal sequences like ../ or absolute paths.
The risk is present in environments where Zed runs with permissions to write to sensitive locations beyond the extension directory.
Exploit preconditions
- Attack surface: Extension ZIP archive extraction mechanism.
- Required access: Ability to cause Zed to download or load a crafted extension ZIP (e.g., publishing a malicious extension, compromising an extension distribution source, or manipulating extension URLs).
- Trigger point: Zed invokes
extract_zip()on the attacker-controlled ZIP file during extension installation or update. - Why exploitation is possible: The extraction routine does not normalize and validate ZIP entry filenames before writing them to disk, allowing
../or similar sequences to traverse out of the target extraction directory.
Why this happens
This issue stems from insufficient validation of file paths contained within ZIP archives during extraction.
The extract_zip() function trusts the file names recorded in the archive and directly concatenates them with the target directory, without canonicalization or checks to enforce that resulting paths remain inside the intended sandbox.
Conceptually, this is a classic CWE-22: Path Traversal pattern in the specific form known as Zip Slip, where untrusted archive metadata is used to construct filesystem paths, enabling writes outside the designated directory.
Potential impact
- Malicious extensions could write files outside their sandboxed directory.
- Overwriting of user configuration or application files that Zed can access.
- Planting of malicious scripts or binaries in locations writable by the Zed process.
- Assisting in privilege escalation or persistence when combined with other weaknesses (e.g., auto-loaded configuration, plugins, or startup scripts).
- Integrity impact on project source code if the process has write access to workspace files.
General mitigation guidance
Effective mitigation focuses on enforcing robust path safety during archive extraction and constraining the impact of untrusted extensions:
- Normalize and canonicalize each ZIP entry path before writing, then verify it is strictly contained within the intended extraction directory (e.g., via prefix checks on canonical paths).
- Explicitly reject entries containing
.., absolute paths, or platform-specific path tricks (such as leading separators or drive letters). - Enforce a tight allowlist of acceptable paths and file types within extension archives.
- Apply least-privilege principles so the editor process and its extension handling cannot write to highly sensitive system locations.
- Treat extension archives as untrusted input and isolate their handling where possible (e.g., via sandboxing or separate processes with restricted filesystem permissions).
How teams detect issues like this
Detection can focus on both code-level patterns and runtime behavior:
- Static analysis / code scanning: Identify archive extraction code that:
- Uses ZIP entry names directly when constructing filesystem paths.
- Lacks canonicalization and containment checks against a base directory.
- Does not explicitly reject
.., absolute paths, or unusual path prefixes. - Code review signals:
- Manual reviewers should look for file extraction loops that do not validate or normalize paths.
- Check that any path-joining function is followed by safe containment checks.
- Policy enforcement:
- Enforce development guidelines requiring safe archive extraction helpers and banning ad-hoc extraction logic.
- Integrate security linters or SAST tools into CI pipelines to flag path traversal patterns.
- Runtime monitoring (where applicable):
- Monitor for extension installation events resulting in file writes outside expected extension directories, if the platform and environment provide sufficient auditing.

