/

CVE-2026-82639

Severity:

HIGH RISK

(7.5)

Improper URL Validation (CWE-20) in NextChat Proxy Endpoint

CVE-2026-82639

Deferred

Vulnerability type

Category:

Improper Input Validation

CWE:

CWE-20

Impact:

Sensitive Credential Disclosure

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

NextChat contains an improper URL validation flaw in its proxy endpoint. Because the x-base-url header is checked with substring matching rather than hostname parsing, an attacker may cause the server to send its OpenAI API key to an attacker-controlled destination.

Affected context

The vulnerability affects NextChat versions 2.15.8 through 2.16.1 when the proxy endpoint processes the x-base-url header and uses substring matching to decide whether a destination is trusted. The risk exists when an attacker can reach the proxy endpoint and supply a URL containing the expected OpenAI hostname text without that hostname being the actual destination.

Exploit preconditions

  • Attack surface: NextChat's network-accessible proxy endpoint
  • Required access: Ability to send requests to the proxy endpoint; authentication requirements depend on deployment configuration
  • Trigger point: Processing and validation of the x-base-url request header
  • Why exploitation is possible: Substring matching can accept attacker-controlled URLs that merely contain the trusted hostname text, causing the server to attach its OpenAI API key to a request sent to an unintended destination

Why this happens

The underlying bug is improper input validation under CWE-20. The proxy treats a URL as trusted when it contains an approved hostname string, rather than parsing the URL and comparing its canonical hostname and relevant components against an explicit allowlist. This insecure pattern confuses text presence with authority and can allow sensitive authorization headers to cross the intended trust boundary.

Potential impact

  • An attacker may obtain the server's OpenAI API key.
  • Exposed credentials could enable unauthorized use of the associated OpenAI account.
  • The disclosure could result in unexpected costs, quota consumption, or service disruption.
  • Compromised credentials could expand the impact to other systems if they are reused or broadly privileged.

General mitigation guidance

Mitigation generally focuses on making URL handling parser-based and reducing

trust in attacker-controlled routing inputs.

Common defensive patterns include:

  • Parse URLs with a standards-compliant library instead of using substring or prefix checks.
  • Compare canonical hostnames against a narrowly defined allowlist, while separately validating schemes, ports, and user-information components.
  • Avoid forwarding authorization headers to destinations that are not explicitly trusted.
  • Keep API keys server-side, scope them to the minimum required permissions, and use short-lived or separately restricted credentials where supported.
  • Treat proxy destination headers as untrusted input and apply secure-by-default routing policies.
  • Add regression tests for lookalike hostnames, alternate ports, redirects, and URL parsing edge cases.

How teams detect issues like this

Organizations can look for this issue through:

  • Static analysis rules identifying substring, prefix, or regular-expression checks used for URL trust decisions.
  • Code review of proxy handlers that accept destination URLs through request headers or parameters.
  • Tests that verify canonical hostname and scheme validation across ambiguous URL forms.
  • Network monitoring for outbound requests from the application to unexpected domains.
  • Secret-scanning and log review to identify API keys or authorization headers appearing in outbound traffic or application logs.
  • Policy enforcement requiring centralized URL parsing and allowlist utilities for server-side proxy components.

Sources

SourceLink
github.comgithub.com/ChatGPTNextWeb/NextChat
github.comgithub.com/ChatGPTNextWeb/NextChat/blob/v2.16.1/app/api/proxy.ts
github.comgithub.com/ChatGPTNextWeb/NextChat/issues/6814
vulncheck.comvulncheck.com/advisories/nextchat-2.15.8-through-2.16.1-openai-api-key-disclosure

Frequently asked

questions

It may be remotely exploitable when an attacker can reach the affected proxy

endpoint and influence the x-base-url header. The exact scope depends on

network exposure and authentication controls.

The attacker needs access to submit requests to the proxy endpoint. Whether

authentication is required depends on how the NextChat deployment is configured.

Parse the supplied URL structurally and permit only explicitly approved,

canonical hostnames and schemes. Authorization headers should not be forwarded

to destinations that fail those checks.

Centralize URL validation, avoid substring-based trust decisions, add adversarial

URL test cases, restrict outbound network access, and monitor for unexpected

credential-bearing requests.

Find out what's already
exploitable in your codebase.