Unauthenticated Path Traversal in text-generation-webui allows arbitrary file reads
Overview
The text-generation-webui application, a popular open-source interface for interacting with Large Language Models (LLMs), suffers from an unauthenticated path traversal vulnerability in its `load_template()` function. This vulnerability affects versions prior to 4.3. An attacker can exploit this by crafting a malicious request that manipulates the file path parameter passed to `load_template()`. This allows the attacker to traverse directory structures and read sensitive files on the server's filesystem, provided they have extensions of `.jinja`, `.jinja2`, `.yaml`, or `.yml`. For `.jinja` and `.jinja2` files, the content is returned directly to the attacker. For `.yaml` and `.yml` files, the application attempts to parse them and extract a specific key, which can still reveal sensitive information or configuration details. This could lead to exposure of API keys, credentials, configuration settings, or other sensitive data stored in these file types, compromising the security of the entire system.
Affected Systems
Testing Guide
* **Step 1:** Ensure you have a vulnerable version of text-generation-webui installed. * **Step 2:** Construct a malicious request targeting the `load_template()` endpoint. For example, try to access a sensitive file like `/etc/passwd` or a configuration file within the application's directory using path traversal sequences (e.g., `../../../../etc/passwd`). * **Step 3:** Analyze the response for the content of the requested file. If the file content is returned, the system is affected. * **Step 4:** Test with various file extensions (`.jinja`, `.jinja2`, `.yaml`, `.yml`) to confirm the scope of the vulnerability.
Mitigation Steps
* Upgrade text-generation-webui to version 4.3 or later. * Implement strict input validation on any user-supplied file path parameters. * Restrict read access to sensitive configuration and template files to only necessary processes. * Deploy a Web Application Firewall (WAF) to detect and block path traversal attempts.
Patch Details
Version 4.3