/

CVE-2026-25640

Severity:

HIGH RISK

(7.1)

Client-Side Code Injection via Path Traversal

CVE-2026-25640

Modified

Vulnerability type

Category:

Client-Side Code Injection via Path Traversal

CWE:

CWE-22, CWE-79

Impact:

Arbitrary JavaScript Execution in User Browser (XSS-like Impact)

Severity:

HIGH RISK

(7.1)

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 the Pydantic AI web UI's CDN URL construction allows an attacker to inject arbitrary JavaScript into the application's browser context via a crafted URL.

By abusing an unvalidated version query parameter, an attacker can cause the server to serve attacker-controlled HTML/JS from the CDN, leading to theft of chat history and other client-side data when a victim loads the malicious link.

Affected context

This vulnerability affects applications that:

  • Use Agent.to_web to expose a chat UI, or
  • Use the clai web command to run a chat interface from the CLI.

In these setups, the server-side handler constructs a CDN URL for the chat UI assets based on a version query parameter from the incoming HTTP request. Because this parameter is not validated or normalized, an attacker can embed path traversal sequences that cause the server to pull and relay HTML/JS from an unintended location on the same CDN. The issue manifests whenever users open untrusted links to the affected web UI, whether hosted on localhost or on a remote server.

Exploit preconditions

  • Attack surface: HTTP interface of the Pydantic AI web UI (Agent.to_web or clai web).
  • Required access: Ability to convince a victim to visit a crafted URL (e.g., link sharing, phishing, iframe embedding); no prior authentication is inherently required by the vulnerability itself.
  • Trigger point: A malicious request containing a specially crafted version query parameter that induces path traversal in the constructed CDN asset URL.
  • Why exploitation is possible: The server trusts the version parameter, concatenates it into the CDN path without validation or canonicalization, and then fetches and serves the resulting resource. This enables an attacker to redirect the asset load to attacker-controlled HTML/JS already present on the same CDN, which then runs in the trusted origin of the chat UI.

Why this happens

The underlying issue is improper input handling in URL construction combined with implicit trust in remotely loaded resources.

The web UI code takes a version query parameter from the request and interpolates it into the CDN asset path without:

  • Validating it against an allowlist of expected version formats, or
  • Normalizing the path to prevent ../-style traversal.

This maps to CWE-22: Path Traversal because untrusted input is used to navigate within a remote resource hierarchy. The resulting behavior leads to CWE-79-like impact because the server ends up proxying attacker-selected HTML/JavaScript that executes in the victim's browser under the application's origin. Conceptually, this is a client-side code injection problem caused by server-side URL composition that fails to constrain the resource location.

Potential impact

  • Theft of chat history and other sensitive data stored in the browser for the affected Pydantic AI interface.
  • Exfiltration of API keys, tokens, or configuration data exposed in the web UI or stored in local/session storage.
  • Impersonation of the user within the chat session, including sending or modifying messages on their behalf.
  • Injection of misleading or malicious UI elements, potentially tricking users into revealing additional sensitive information.
  • Use of the compromised browser context as a pivot to attempt further attacks within the same origin or adjacent application features.

General mitigation guidance

Effective mitigation focuses on constraining how remote assets are addressed and reducing trust in client-supplied parameters:

  • Restrict and validate version parameters:
  • Treat version identifiers as data, not paths—enforce a strict pattern (e.g., semantic version or short tag) and reject any value containing slashes, traversal sequences, or URL control characters.
  • Prefer an explicit allowlist of known-good versions when dynamic selection is required.
  • Avoid raw concatenation for URL paths:
  • Use structured URL builders or path-joining utilities that operate on validated tokens rather than raw string concatenation.
  • Normalize and canonicalize paths before use, and fail closed on any attempt to escape an expected directory.
  • Limit the scope of remote content loading:
  • Constrain asset fetching to fixed, known paths on the CDN and keep the asset identifier separate from the directory structure.
  • Avoid serving arbitrary HTML content fetched based on user-controlled parameters; fetch static assets whose location is pre-determined.
  • Harden the browser environment where possible:
  • Apply security headers such as Content Security Policy (CSP) to restrict script execution sources, reducing the impact of unintended HTML/JS being served.
  • Minimize sensitive data stored in the browser and ensure that secrets or credentials are not exposed in the front-end unless strictly necessary.
  • Apply least-privilege design for UI data:
  • Only expose the minimum data required for the chat interface to function, and keep sensitive operational or debugging information out of the client.

How teams detect issues like this

Detection is best approached through a mix of code analysis, configuration review, and behavioral monitoring:

  • Static analysis and code review:
  • Search for instances where query parameters (e.g., version) are concatenated into URLs or file paths without validation.
  • Flag patterns where user input is used in CDN or asset URLs, especially when combined with ../ or other path-like constructs.
  • Review web UI routing and asset-serving handlers to ensure they do not proxy arbitrary HTML/JS based on request parameters.
  • Automated security scanning:
  • Use dynamic application security testing (DAST) tools to probe for path traversal via query parameters and to detect unexpected HTML/JS served when parameters contain traversal sequences.
  • Integrate URL and parameter sanitization checks into CI/CD pipelines to catch unsafe patterns early.
  • Runtime monitoring:
  • Log full request paths and selected query parameters for the web UI endpoints, and alert on anomalous versions containing slashes or traversal patterns.
  • Monitor for unusual asset fetch patterns to the CDN from the application, such as requests for non-standard or unexpected paths.
  • Policy and coding standards:
  • Establish guidelines that prohibit using unvalidated client input for path or URL construction.
  • Encourage use of centralized helpers for safe URL/path generation so deviations are easier to spot and audit.

Sources

SourceLink
github.comgithub.com/pydantic/pydantic-ai/releases/tag/v1.51.0
github.comgithub.com/pydantic/pydantic-ai/security/advisories/GHSA-wjp5-868j-wqv7
access.redhat.comaccess.redhat.com/security/cve/CVE-2026-25640
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2437753
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-25640.json

Frequently asked

questions

Yes. If the web UI is accessible over a network (including via port forwarding or exposure from localhost), an attacker can send or publish a crafted URL. Exploitation occurs when a victim's browser loads that URL and the server fetches and serves the attacker-selected content from the CDN.

Not inherently. The vulnerability is tied to how the version parameter is processed for asset loading, not to authentication. However, the impact depends on what data is available to the victim's browser; if sensitive chat history or tokens are only present for authenticated users, the attacker benefits most when the targeted victim is already authenticated in the web UI.

Constrain and validate the version parameter so that it cannot influence directory traversal or arbitrary paths, and ensure that the server only loads UI assets from fixed, known-good locations on the CDN. In practice, that means using a strict allowlist or pattern for version strings and using robust URL/path construction utilities instead of direct string concatenation.

Avoid using user-controlled values in URLs or paths that determine which HTML/JS content is served, enforce strong input validation and canonicalization on all path- or URL-related parameters, and apply defense-in-depth via CSP and minimal client-side data exposure. Embedding these rules into coding standards and automated checks helps prevent regressions and new instances of the same flaw class.

Find out what's already
exploitable in your codebase.