Summary
Plandex contains a path traversal vulnerability in its ApplyFiles function, allowing attacker-influenced model output or repository context to cause files to be written outside the intended project directory. If sensitive filesystem locations are reachable and the affected process has sufficient permissions, this could enable code execution through modified shell or scheduled-task configuration.
Affected context
The issue occurs in Plandex deployments that use the ApplyFiles function to apply file changes generated from model output or repository-derived context. Risk increases when repository contents or contextual inputs can be poisoned, when generated paths are not confined to the project directory, and when the Plandex process has write access to user or system execution-related files.
Exploit preconditions
- Attack surface: The ApplyFiles file-writing functionality
- Required access: The ability to influence repository files, task context, or model-directed file changes
- Trigger point: Processing and writing attacker-influenced file paths
- Why exploitation is possible: File paths are insufficiently constrained to the intended project directory, allowing traversal outside the permitted root
- Privilege dependency: The resulting impact depends on the filesystem permissions of the Plandex process
Why this happens
The vulnerability is caused by accepting attacker-influenced paths without reliably canonicalizing them and enforcing containment within the designated project directory. Relative traversal sequences or equivalent path representations can cause file operations to escape the intended directory boundary. This maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, commonly known as path traversal.
Potential impact
- Attackers may overwrite files outside the project directory
- Shell startup or scheduled-task files could be modified
- The affected user account may execute attacker-controlled commands
- Application data, source code, or configuration could be tampered with
- The incident could enable persistence or broader compromise depending on process privileges
General mitigation guidance
Mitigation generally focuses on treating generated paths and repository-derived filenames as untrusted input.
Common defensive patterns include:
- Canonicalizing candidate paths before file operations
- Enforcing a strict project-root containment check after canonicalization
- Rejecting absolute paths, traversal components, and ambiguous path encodings
- Allowing writes only to an explicit list of expected files or directories
- Separating model output from privileged filesystem operations through approval or policy checks
- Running the application with the minimum filesystem permissions required
- Using isolated workspaces and read-only access to sensitive locations where practical
How teams detect issues like this
Organizations can look for:
- Static analysis rules identifying file writes that use unsanitized or model-controlled paths
- Code review signals involving path joins without canonicalization and root-containment checks
- Tests covering absolute paths, traversal segments, symbolic links, and alternate path representations
- Runtime audit events for writes outside the configured project directory
- Policy enforcement that restricts automated agents from modifying shell, scheduler, credential, or system configuration files
Automated security review tools may help identify unsafe path handling, but findings should be confirmed against deployment permissions and filesystem behavior.

