text-generation-webui Path Traversal Vulnerability Allows Sensitive File Disclosure
Overview
The text-generation-webui application, a popular open-source interface for interacting with Large Language Models, is affected by a critical path traversal vulnerability. Specifically, in versions prior to 4.3, the `load_preset()` function fails to properly sanitize user-supplied input. This allows an unauthenticated attacker to craft a malicious request that exploits the path traversal flaw. By providing an attacker-controlled path, an attacker can trick the application into reading arbitrary files from the server's filesystem that have a `.yaml` extension. The contents of these files are then parsed as YAML key-value pairs. Crucially, sensitive information such as passwords, API keys, database connection strings, and other configuration details embedded within these YAML files can be exfiltrated and returned directly in the API response, posing a significant security risk.
Affected Systems
Testing Guide
1. Ensure you have access to a vulnerable version of text-generation-webui (prior to 4.3). 2. Craft a request targeting the `load_preset()` endpoint (e.g., POST to `/api/load_preset` or similar, depending on the exact API structure). 3. In the request body, provide a payload that attempts to traverse directories and access a sensitive YAML file, for example: `{"name": "../../../../etc/passwd.yaml"}` (replace with a known sensitive YAML file on the target system if possible). 4. Analyze the API response for any leaked content from the specified file. If file contents are returned, the system is vulnerable.
Mitigation Steps
* Update text-generation-webui to version 4.3 or later. * Implement strict input validation on all user-supplied file path parameters. * Limit the permissions of the user account running the text-generation-webui service. * Consider using a Web Application Firewall (WAF) to block suspicious path traversal patterns.
Patch Details
Version 4.3