Summary
Pake's download_file Tauri command can combine a JavaScript-supplied filename with the user's Downloads directory without sanitizing path components. A script that can invoke the command may cause attacker-controlled content to be written outside that directory, potentially enabling user-account code execution through startup or login persistence locations.
Affected context
The vulnerability occurs in desktop applications generated from an affected Pake codebase when the download_file command accepts filename and URL values from JavaScript. The risk exists when an untrusted script can invoke the command and the supplied filename is interpreted as a relative traversal path or absolute filesystem path. The command performs the download through Rust and writes the returned content to the resolved destination, so browser-origin restrictions do not necessarily protect the filesystem operation.
Exploit preconditions
- Attack surface: The Tauri command bridge exposed by a Pake-generated desktop application
- Required access: Ability to execute or influence JavaScript that can invoke
download_file - Trigger point: Filename resolution and file creation after the requested URL is fetched
- Why exploitation is possible: The filename is joined to the Downloads directory without canonicalization, containment checks, or rejection of absolute paths
- Content requirement: The attacker must be able to control or influence the downloaded URL or its returned content
Why this happens
The underlying bug is a failure to treat a JavaScript-provided filename as untrusted filesystem input. Joining an attacker-controlled path with an intended base directory does not guarantee that the resulting path remains beneath that directory; traversal components and absolute paths can escape the base location. This behavior maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, commonly known as path traversal. The unrestricted write operation is especially dangerous because user-writable startup and autostart locations can cause subsequently launched content to execute with the user's privileges.
Potential impact
- Arbitrary files in user-writable locations may be overwritten
- Malicious content may be placed in macOS LaunchAgents, Linux autostart, or Windows Startup locations
- Code may execute in the affected user's account after login or application startup
- User data or application configuration may be corrupted
- Persistence may be established within the desktop environment
- Other Pake-generated applications sharing the affected command pattern may expose the same risk
General mitigation guidance
Mitigation generally focuses on enforcing a strict destination boundary and minimizing the command's filesystem authority.
Common defensive patterns include:
- Accepting only a generated basename or tightly constrained filename rather than arbitrary path text
- Rejecting absolute paths, traversal segments, encoded traversal forms, and platform-specific alternate path syntax
- Canonicalizing the candidate path and verifying that it remains within the intended Downloads directory
- Using safe file-creation APIs that do not follow unexpected links or replace unrelated files
- Separating download retrieval from filesystem placement and applying an explicit allowlist of permitted destinations
- Restricting Tauri command exposure and validating all JavaScript-originated arguments at the native boundary
- Applying least-privilege filesystem permissions and avoiding write access to startup or autostart locations
- Requiring user-visible consent for downloads and treating downloaded files as untrusted content
How teams detect issues like this
Organizations can identify similar issues through:
- Static analysis rules for filesystem joins involving request, JavaScript, or IPC-controlled path values
- Code review checks for missing canonicalization, containment validation, and absolute-path rejection
- Tests using traversal sequences, encoded separators, symlink scenarios, and platform-specific path formats
- Tauri capability and permission reviews that inventory commands able to write files
- Runtime monitoring for unexpected writes outside designated download directories
- Endpoint policy alerts for new or modified startup, autostart, and login-agent files
Automated code review and security scanning tools may help flag dangerous path construction patterns, but their findings should be validated against platform-specific filesystem behavior.

