/

CVE-2026-35485

Severity:

HIGH RISK

(7.5)

Path Traversal in text-generation-webui load_grammar File

CVE-2026-35485

Analyzed

Vulnerability type

Category:

Path Traversal / Directory Traversal

CWE:

CWE-22

Impact:

Arbitrary File Read on Server

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

An unauthenticated path traversal vulnerability in text-generation-webui before version 4.3 allows arbitrary file reads from the server filesystem via the load_grammar() functionality.

By abusing unvalidated dropdown values over the Gradio API, an attacker can submit directory traversal payloads (such as ../../../etc/passwd) and receive the full contents of targeted files in the server response.

Affected context

This vulnerability appears in deployments of text-generation-webui that expose the Gradio-based HTTP API or web interface to a network where untrusted users can send requests.

It specifically involves the grammar-loading feature, which accepts a file path from a dropdown or API parameter and then reads that file from disk.

Because the server does not constrain or sanitize these paths before use, a crafted value that navigates outside the intended grammar directory can access arbitrary readable files on the host system.

Exploit preconditions

  • Attack surface: HTTP(S) endpoint provided by the Gradio interface or API.
  • Required access: Network access to the text-generation-webui instance; no prior authentication required in the vulnerable configuration.
  • Trigger point: Invocation of the grammar loading endpoint (e.g., load_grammar()) with a directory traversal payload in the file path parameter.
  • Why exploitation is possible: The server trusts client-supplied dropdown values, lacks server-side normalization and path restriction, and directly uses them in file I/O calls without validating that the resolved path stays within an allowed directory.

Why this happens

The root cause is insufficient validation of file paths supplied by the client before performing filesystem operations, corresponding to CWE-22: Path Traversal.

The load_grammar() routine treats a user-controlled value (originating from a UI dropdown or direct API call) as a trusted file path and passes it directly to file reading logic.

Because the code does not enforce constraints such as base-directory whitelisting, canonical path checks, or rejection of traversal sequences like ../, an attacker can escape the intended grammar directory and read arbitrary files that the server process can access.

Potential impact

  • An attacker may read sensitive configuration files (e.g., containing API keys, access tokens, or service credentials) available to the application user.
  • An attacker could access system files such as /etc/passwd that facilitate reconnaissance and further attacks.
  • Application logs, prompt logs, or conversation histories could be exposed, leaking user data or model interactions.
  • Environment-specific secrets or infrastructure metadata stored on disk may be disclosed, potentially enabling lateral movement or privilege escalation in the environment.

General mitigation guidance

Effective mitigation focuses on constraining file access and hardening how user-supplied paths are handled:

  • Restrict grammar and similar resources to a fixed, server-side configured directory and reject any path that resolves outside this directory after normalization.
  • Avoid trusting client-side UI elements (such as dropdowns) as a security control; always validate on the server.
  • Use safe file selection mechanisms that map user-visible names or IDs to server-side whitelisted paths, instead of letting clients submit arbitrary filesystem paths.
  • Run the application under a dedicated, least-privileged system account with minimal filesystem permissions, so that even if a path traversal occurs, the accessible data is limited.
  • Consider isolating the application in a container or sandbox with a reduced view of the host filesystem, exposing only the files necessary for operation.

How teams detect issues like this

Detection can rely on both code-centric and operational approaches:

  • Static analysis / code review: Look for file operations where request parameters or UI-controlled values are used directly in open(), path joining, or similar APIs without normalization and base-directory checks.
  • Security review patterns: Flag endpoints or callbacks that allow users to select or upload files and verify they enforce strict allowlists or mapping layers rather than raw path usage.
  • Runtime monitoring: Inspect HTTP logs for suspicious patterns such as ../ sequences or absolute paths in parameters associated with grammar or file-loading endpoints.
  • Automated tooling: Incorporate SAST tools or linters configured with rules for CWE-22 to detect potentially unsafe path construction and file access.

Sources

SourceLink
github.comgithub.com/oobabooga/text-generation-webui/security/advisories/GHSA-hqg5-487v-5mc6

Frequently asked

questions

Yes. If the text-generation-webui instance exposes its Gradio interface or API to a network where attackers can reach it and no authentication gate is in place for the grammar-loading feature, the issue can be exploited remotely by sending crafted HTTP requests.

No direct system account on the host is required, and in the described vulnerable configuration, no application-level authentication is necessary. The attacker only needs network access to the exposed service and the ability to send requests to the affected endpoint.

The most robust fix is to remove direct use of user-controlled paths and instead implement a strict server-side mapping from approved identifiers to actual filenames, combined with enforcement of a single, trusted base directory and canonical path checks to prevent directory traversal.

Consistently treat all client-supplied file references as untrusted, normalize and validate paths against a whitelist or fixed base directory, review file-accessing code during development and code review, and use automated checks to flag any file operations that depend on uncontrolled user input.

Find out what's already
exploitable in your codebase.