Summary
SillyTavern versions prior to 1.17.0 contain a path traversal flaw in the /api/chats/import endpoint that allows authenticated users to write files outside the intended chats directory.
By injecting directory traversal sequences into the character_name parameter, an attacker can cause the application to create or overwrite arbitrary files within the server's file system scope.
Affected context
The vulnerability occurs in deployments of SillyTavern where the /api/chats/import functionality is exposed and used by authenticated users to import chat data.
The issue is specifically tied to how the character_name field is incorporated into file paths for storing imported chats, without fully constraining or normalizing the path.
Risk is higher when SillyTavern runs on a multi-user system, shares a host with other sensitive services, or has access to sensitive configuration files and scripts.
Exploit preconditions
- Attack surface: HTTP API endpoint
/api/chats/import - Required access: Valid authenticated user account within SillyTavern
- Trigger point: Submission of an import request where
character_namecontains path traversal sequences (e.g., use of../-style segments) - Why exploitation is possible: The server-side logic uses user-supplied
character_namedirectly when constructing filesystem paths, without canonicalization, strict whitelisting, or enforcement of a fixed root directory, enabling traversal outside the intended chats directory.
Why this happens
The root cause is improper restriction of a pathname to a limited directory (CWE-22), compounded by inadequate control over resource names used for file creation or modification (CWE-73).
The application treats character_name as a benign label but directly interpolates it into filesystem paths for chat storage, failing to:
- Normalize and canonicalize the resulting path
- Reject traversal tokens and absolute paths
- Enforce that the final resolved path remains under the designated chats directory
This insecure pattern allows attackers to influence where files are written, turning a routine import operation into a primitive for arbitrary file placement or overwrite.
Potential impact
- Creation of attacker-controlled files in arbitrary writable locations on the host filesystem
- Overwriting of existing application or configuration files that are writable by the SillyTavern process
- Planting of scripts, configuration fragments, or other artifacts that could later be executed or loaded by other processes
- Interference with SillyTavern data integrity, including corruption or manipulation of other users' chat histories
- In some environments, potential escalation into remote code execution if written files are later interpreted as code or loaded by privileged components
General mitigation guidance
Effective mitigation focuses on constraining filesystem operations to a well-defined, trusted directory and treating all path-related input as untrusted:
- Resolve all user-influenced paths against a fixed base directory and verify, after canonicalization, that the final path still resides within that directory.
- Reject any input containing path separators, traversal tokens, or characters not explicitly allowed by a strict whitelist for
character_name. - Use dedicated APIs or helper utilities for safe path joining that are designed to prevent directory traversal.
- Store files using server-generated identifiers (e.g., UUIDs) and maintain a mapping from logical names to internal paths, rather than embedding user input directly into filenames.
- Run the SillyTavern process under a low-privilege account with restricted write permissions, limiting the blast radius of any unexpected file writes.
How teams detect issues like this
Detection can combine code-centric and operational techniques:
- Static analysis: Search for file and directory operations where user-controlled values (such as
character_name) are concatenated or joined into paths without validation or canonicalization; enforce rules around use of safe path-joining utilities and checks that enforce a fixed root. - Code review: Pay special attention to endpoints that perform import/export, backup, logging, or file upload, verifying that any user-supplied path segments are sanitized and constrained to specific directories.
- Runtime monitoring: Instrument the application or host to log file writes that occur outside expected directories, and alert on unusual write patterns originating from the SillyTavern process.
- Policy enforcement: Incorporate secure coding guidelines for filesystem access into CI/CD, including automated checks for directory traversal patterns and discouraged direct string concatenation for paths.

