Executive brief
Jan is an open-source offline alternative to ChatGPT that runs AI models locally on a user's computer. A vulnerability in Jan's file upload API endpoints allows attackers to write arbitrary files to the system, potentially enabling them to execute malicious code, modify system configurations, or establish persistence through startup scripts—compromising the confidentiality, integrity, and availability of affected systems.
Technical details
The /v1/app/writeFileSync and /v1/app/appendFileSync endpoints in Jan v0.4.12 lack proper input validation and path filtering, enabling arbitrary file write via path traversal attacks (CWE-22, CWE-434). An unauthenticated attacker on the network can send a crafted POST request with relative paths (e.g., "/../../../../../tmp/a.txt") to write or append content to any file on the system. By targeting initialization scripts (.bashrc, /etc/init.d/) or boot items, an attacker can achieve arbitrary code execution and system compromise. The vulnerability affects all versions up to 0.1.11 of the @janhq/core package. Patches are required to implement strict path canonicalization and whitelist allowed write directories.
Affected products
- Jan @janhq/core up to 0.1.11
Timeline
- 2024-06-04: disclosed
- 2024-06-11: advisory