Summary
prompts.chat contains a path traversal flaw in how it processes skill ZIP archives, allowing crafted filenames with traversal sequences (e.g., ../) to escape the intended extraction directory.
An attacker who can supply a malicious skill archive may cause arbitrary files to be written on the client system and potentially overwrite shell initialization files, leading to code execution on the affected machine.
Affected context
The vulnerability arises in environments where prompts.chat accepts skill ZIP archives and extracts them without sanitizing or normalizing embedded file paths.
Risk is present when:
- User-supplied archives are processed without strict server-side validation
- Archive filenames are trusted by client-side or helper tools
- Extraction occurs into user-controlled environments where shell initialization or configuration files exist
In these conditions, traversal sequences inside archive entries may direct writes outside the intended skill directory.
Exploit preconditions
- Attack surface: Skill upload or import mechanisms that accept ZIP archives for prompts.chat.
- Required access: Ability to submit or influence the skill ZIP file that will be processed (e.g., via upload, marketplace, or shared package).
- Trigger point: The moment the vulnerable component extracts the ZIP archive and creates files on disk using the provided filenames.
- Why exploitation is possible: The implementation does not normalize or validate archive entry paths, allowing sequences such as
../to be honored during extraction, which redirects file writes to arbitrary locations outside the target directory.
Why this happens
This is a classic path traversal issue as described by CWE-22, where user-controlled path components are used without sufficient validation when creating or writing files.
The extraction routine appears to:
- Trust file paths embedded in the ZIP archive
- Concatenate them with a base directory without canonicalizing or checking for traversal patterns
- Perform file writes based on these unchecked paths
As a result, an attacker can craft archive entries with ../ segments (or equivalent constructs) that escape the intended skill directory and target sensitive locations, including shell configuration files or startup scripts, which can later be executed by the system.
Potential impact
- Attacker-controlled files can be written to arbitrary locations accessible by the extraction process.
- Overwriting of shell initialization files (e.g., user shell rc files) which may execute attacker-supplied commands on login or shell start.
- Modification of application configuration files, potentially altering behavior or security controls.
- Planting of backdoor scripts or binaries in locations likely to be executed by the user or other software.
- Escalation from a simple file-write bug to full code execution in the context of the affected user or service.
General mitigation guidance
Effective mitigation focuses on treating all archive contents as untrusted and enforcing strict path handling rules:
- Normalize and canonicalize paths from ZIP entries before use, ensuring they remain within an expected base directory.
- Explicitly reject archive entries containing
.., absolute paths, or path components that resolve outside the designated extraction root. - Prefer safe archive extraction utilities or helper functions that provide built-in checks or allow a custom path validation callback.
- Use a strict allowlist for valid skill file locations and extensions, ignoring any entries that do not conform.
- Run archive processing under the least-privileged account possible, without access to sensitive system or user configuration files, and avoid processing in home directories or other locations with login scripts.
How teams detect issues like this
Organizations can detect or prevent this pattern through several high-level strategies:
- Static analysis: Flag code that writes files based on user-controlled paths (including archive entry names) without normalization and boundary checks; identify calls to ZIP extraction APIs where callbacks or validation are missing.
- Code review: Look for archive handling logic that:
- Directly concatenates base directories with entry names
- Lacks checks for
.., absolute paths, or symbolic links - Writes files outside a clearly defined extraction root
- Runtime monitoring: Use filesystem monitoring or sandboxing to detect unexpected writes outside designated skill directories during archive extraction.
- Policy enforcement: Incorporate secure file and archive handling guidelines into development standards, and use CI checks to enforce use of safe helper functions for extraction.

