Summary
SillyTavern chat endpoints contain a path traversal flaw that allows an authenticated user to manipulate avatar paths and access files outside the intended directory.
By supplying crafted avatar_url values such as "..", an attacker can read or delete arbitrary files within their user data root, including sensitive configuration files like secrets.json and settings.json.
Affected context
This vulnerability occurs in SillyTavern deployments where the chat avatar handling logic accepts user-controlled paths and resolves them against a user data directory.
It is relevant when:
- Users can authenticate and modify avatar-related settings or requests
- The server accepts avatar_url or similar parameters without strict normalization or whitelisting
- File operations are performed based on those paths relative to a user data root
The issue is scoped to files accessible under the authenticated user's data root, such as secrets.json, settings.json, or other configuration files stored there.
Exploit preconditions
- Attack surface: HTTP(S) chat or profile-related endpoints that accept an avatar_url or similar file path parameter.
- Required access: Valid authenticated access to SillyTavern under a given user account; no direct OS-level access required.
- Trigger point: Submitting a crafted request (e.g., setting avatar_url to
".."or related traversal sequences) that causes the server to resolve and operate on unintended file paths. - Why exploitation is possible: The server-side code trusts the incoming avatar path, concatenates it with the user data root, and performs file operations without fully normalizing the path or enforcing that the resolved path stays within the intended directory.
Why this happens
The underlying bug is a classic directory traversal issue mapped to CWE-22: Improper Limitation of a Pathname to a Restricted Directory.
The application uses user-controlled input (avatar_url) to build filesystem paths under a user data root, but:
- It does not neutralize traversal tokens such as
..or mixed encodings. - It does not canonicalize and verify the final resolved path against the intended base directory before reading or deleting files.
This insecure pattern allows a user to escape the designated avatar directory and target arbitrary files beneath their data root, enabling unintended read and delete operations.
Potential impact
- An authenticated user may read sensitive files under their user data root (e.g., secrets.json, settings.json).
- An attacker could delete configuration or state files, potentially causing data loss or service disruption for that user account.
- Compromise of stored tokens, API keys, or other secrets that are persisted within the affected user data directory.
- Facilitation of further attacks, such as account misuse or session hijacking, if secret material is exposed.
General mitigation guidance
Mitigation focuses on enforcing strict path handling and reducing trust in user-supplied file paths:
- Normalize and canonicalize all user-controlled paths and verify they remain within the intended base directory before use.
- Replace arbitrary file path parameters with indirect references (e.g., IDs mapped to known safe filenames) rather than raw path segments.
- Implement allowlists of valid avatar locations or filenames instead of accepting free-form paths.
- Use filesystem APIs or helper routines that enforce a fixed root and refuse operations when a path escapes that root.
- Minimize the storage of highly sensitive data in locations reachable by any user-controlled file operation, and apply least-privilege file permissions wherever possible.
How teams detect issues like this
Effective detection strategies involve both code-centric and operational approaches:
- Static analysis: Configure rules to flag concatenation of user input into filesystem paths, especially when combined with
..or lack of canonicalization checks. - Code review: Look for handlers that:
- Accept parameters like avatar_url, path, file, or filename.
- Construct paths by string concatenation with a base directory but do not verify the normalized result is still under that base.
- Unit and integration tests: Add tests that attempt traversal payloads (e.g.,
../secrets.json) and assert that access is denied. - Runtime monitoring: Where feasible, log and alert on suspicious path patterns in requests (e.g., repeated
..segments or encoded traversal attempts), while avoiding logging sensitive file contents.

