/

CVE-2026-65700

Severity:

CRITICAL RISK

(9.8)

Path Traversal (CWE-22) in h2oGPT Files API

CVE-2026-65700

Deferred

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Arbitrary File Read/Write and Remote Code Execution

Severity:

CRITICAL RISK

(9.8)

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

A path traversal flaw in h2oGPT's OpenAI-compatible files API allows bearer token values to be treated as filesystem paths without proper sanitization.

Because the default API key is effectively empty and the token is used directly in directory resolution, unauthenticated attackers can read, modify, and delete arbitrary server-side files, potentially leading to remote code execution.

Affected context

This vulnerability affects deployments of h2oGPT (through version 0.2.1) that expose the OpenAI-compatible files API over a network interface.

The issue manifests where the get_user_dir function in openai_server/backend_utils.py constructs per-user directories by directly incorporating the bearer token into a filesystem path.

Installations using default or weak API key configurations, especially those retaining the EMPTY default key, are particularly exposed because authentication can be bypassed and any token value is interpreted as a directory path component.

Exploit preconditions

  • Attack surface: Network-exposed OpenAI-compatible files API endpoints (e.g., file upload, content retrieval, deletion).
  • Required access: No prior authentication when default or ineffective API keys are in place; an attacker only needs HTTP access to the service.
  • Trigger point: Supplying a crafted bearer token containing directory traversal sequences (such as parent directory references) and then invoking file-related endpoints.
  • Why exploitation is possible: The bearer token is treated as a trusted, opaque identifier and is passed unsanitized into os.path.join, allowing traversal outside the intended user directory and direct interaction with arbitrary filesystem locations accessible to the server process.

Why this happens

The underlying defect arises from using unvalidated user-controlled data as part of a filesystem path, without canonicalization or restriction to an expected directory root.

In this design, the bearer token—intended to serve as an authentication credential—is repurposed as a directory name and concatenated directly using os.path.join, effectively granting the client control over which directory the application reads from or writes to.

This pattern maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, where the application fails to enforce that paths remain within a safe base directory, and does not normalize or reject path traversal sequences before use.

The risk is amplified by the default configuration that sets the API key to EMPTY, collapsing the boundary between authentication and path selection and enabling unauthenticated arbitrary file access.

Potential impact

  • Arbitrary file read of configuration files, secrets, or source code accessible to the server process.
  • Arbitrary file write to locations such as startup hooks, plugin directories, or interpreted code files, which can enable remote code execution.
  • Deletion of critical application or system files, leading to denial of service or persistent service degradation.
  • Tampering with model artifacts, data files, or logs, undermining integrity and auditability.
  • Pivoting to broader system compromise if sensitive credentials or keys are retrieved from the filesystem.

General mitigation guidance

Effective mitigation centers on enforcing strict separation between authentication data and filesystem paths, and constraining all file operations to well-defined directories.

Recommended patterns include:

  • Derive user directories from internal identifiers or keyed mappings rather than directly from bearer tokens or other client-provided strings.
  • Normalize and validate all filesystem paths against a fixed, canonical base directory, rejecting any request that attempts to reference parent directories or absolute paths.
  • Introduce robust authentication and authorization checks before file operations, avoiding permissive defaults such as empty API keys, and ensuring fail-closed behavior when credentials are missing or invalid.
  • Use least-privilege execution environments for the application process, limiting the filesystem regions it can access and write to, especially excluding system directories and code execution paths.
  • Implement configuration hardening so that startup hooks, plugin directories, and code-loading paths are read-only at runtime wherever feasible.

How teams detect issues like this

Detecting this class of issue typically involves both code-centric and operational approaches.

On the code and configuration side:

  • Apply static analysis rules that flag uses of os.path.join, open, or equivalent filesystem APIs where any component is derived directly from HTTP headers, tokens, or other untrusted inputs without validation.
  • During code review, scrutinize any logic that converts authentication credentials into filesystem paths, ensuring that identifiers are mapped through internal lookups rather than concatenated directly.
  • Enforce security policies that disallow default or empty API keys in deployed environments, with automated configuration linting to catch insecure settings before deployment.

On the operational side:

  • Monitor access logs for unusual bearer token formats containing path traversal patterns or unexpected characters.
  • Use file integrity monitoring on critical directories (configuration, code, startup hooks) to detect unauthorized file creation, modification, or deletion that may stem from exploited file APIs.

Sources

SourceLink
github.comgithub.com/geo-chen/oss/blob/main/h2ogpt.md
vulncheck.comvulncheck.com/advisories/h2ogpt-path-traversal-via-openai-compatible-files-api

Frequently asked

questions

In environments running affected versions of h2oGPT with the OpenAI-compatible files API exposed and default or weak API key configurations, the vulnerability can be exploited remotely by any party able to reach the service, making it broadly exploitable in typical cloud or internet-facing deployments.

No, not necessarily. Because the default API key is EMPTY and the bearer token is not strictly validated, an attacker can often supply arbitrary tokens and still reach the vulnerable file operations, effectively bypassing authentication.

The most robust fix is to decouple authentication credentials from filesystem paths, derive user directories from internally controlled identifiers, and enforce strict path normalization and base-directory checks for all file operations, while simultaneously enforcing non-empty, properly validated API keys.

Adopt a consistent defensive pattern where all paths are resolved relative to a fixed root, reject any input containing traversal sequences, and treat all client-controlled strings—including headers and tokens—as untrusted; complement this with secure-by-default authentication, rigorous code review for filesystem interactions, and automated checks in CI/CD pipelines to catch unsafe path constructions early.

Find out what's already
exploitable in your codebase.