/

CVE-2026-27590

Severity:

CRITICAL RISK

(9.8)

Input Validation and Path Normalization Error

CVE-2026-27590

Analyzed

Vulnerability type

Category:

Input Validation and Path Normalization Error

CWE:

CWE-20, CWE-180

Impact:

Remote Code Execution via Path Confusion in FastCGI/PHP Setups

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

Caddy's FastCGI path splitting logic previously computed the split index on a lowercased copy of the URL path, then applied that index to the original UTF-8 path. Because lowercasing can change the byte length of some Unicode characters, this could cause Caddy to derive incorrect SCRIPT_NAME/SCRIPT_FILENAME and PATH_INFO values.

In configurations where FastCGI is used to execute PHP and attackers can influence on-disk files (e.g., upload areas), this path confusion may cause unexpected PHP execution of non-.php files, which can lead to remote code execution depending on the environment.

Affected context

The vulnerability manifests in Caddy deployments that:

  • Use the FastCGI handler to serve PHP (or similar) based on URL paths, and
  • Rely on .php or similar extensions in the request path to determine which script is executed, and
  • Handle paths that may include Unicode characters affected by case-folding in UTF-8, and
  • Allow attackers some influence over on-disk file contents or locations (e.g., via file uploads or writable directories).

Under these conditions, the mismatch between the lowercased copy used for path splitting and the original path used for slicing can cause Caddy to send a different file to the PHP interpreter than the one the configuration appears to target.

Exploit preconditions

  • Attack surface: HTTP(S) request handling in Caddy when routing to a FastCGI backend (commonly PHP-FPM).
  • Required access: Ability to send crafted HTTP requests to the server; higher impact if the attacker can also upload or control files in directories that Caddy and the FastCGI backend can access.
  • Trigger point: A request path containing specific Unicode characters and .php (or other FastCGI-targeted suffix) that passes through Caddy's FastCGI path splitting logic.
  • Why exploitation is possible: The split position for the path is calculated on a lowercased version of the path, but that byte index is applied to the original path string. When strings.ToLower() changes the UTF-8 byte length of characters before the split point, the computed index no longer aligns with character boundaries in the original string, leading to incorrect SCRIPT_NAME/SCRIPT_FILENAME and PATH_INFO.

Why this happens

The root cause is a mismatch between logical and byte-level operations during path normalization and splitting, combined with insufficient validation of derived path components.

Specifically, Caddy:

  • Lowercased the request path using strings.ToLower(), which can change the number of bytes used to represent certain Unicode characters in UTF-8.
  • Calculated the FastCGI split index (e.g., position of .php) on this modified, lowercased path.
  • Applied that byte index back to the original path string to derive SCRIPT_NAME/SCRIPT_FILENAME and PATH_INFO.

This behavior corresponds to:

  • CWE-180: Incorrect Behavior Order: Validate Before Canonicalization, because the system operates on a transformed version of the input and then reuses indices on the original representation, effectively making decisions on one canonical form and applying them to another.
  • CWE-20: Improper Input Validation, because the server assumes that the path transformation is length-preserving and that indices calculated on one representation remain valid on the original input without explicit checks.

The insecure pattern, abstractly, is: computing security-critical split points or routing decisions on a transformed string (case-folded, normalized, decoded) and then applying those decisions to a different representation of the input, especially in a multi-byte encoding context.

Potential impact

  • Requests containing .php in the path may execute a different physical file than the one the configuration seems to target.
  • Non-.php files under attacker influence could be interpreted as PHP by the FastCGI backend, leading to possible remote code execution when the file contents are treated as executable script.
  • Bypass of access controls or routing rules that rely on the intended mapping of URL paths to script files.
  • Unexpected disclosure or manipulation of data via execution of unintended scripts or handler logic.
  • Increased difficulty for defenders to reason about which requests execute which on-disk resources, complicating audits and incident response.

General mitigation guidance

Resilient mitigation focuses on making path handling Unicode- and encoding-safe, and avoiding ambiguous routing decisions:

  • Align transformations and indices:
  • Perform all path parsing, extension detection, and splitting on a single, canonical representation of the path.
  • Avoid reusing indices computed on transformed strings (lowercased, normalized, decoded) to slice different string representations.
  • Unicode-safe normalization:
  • Normalize paths in a way that preserves byte offsets when you intend to reuse indices (e.g., operate on runes consistently, or convert both detection and slicing logic to the same representation).
  • Treat any transformation that can change length (such as case folding for certain Unicode code points) as non-safe for index sharing.
  • Strict FastCGI routing rules:
  • Use explicit, configuration-driven script mappings rather than relying solely on dynamic splitting based on path content.
  • Constrain which directories and files can be executed by FastCGI with dedicated root/document-root settings.
  • Reduce trust in writable areas:
  • Avoid allowing FastCGI to execute files from directories where untrusted users can upload or modify content.
  • Segregate upload directories from executable script directories, and configure the server so that upload locations are never treated as executable.
  • Harden the runtime environment:
  • Run FastCGI/PHP workers with least privilege and restrict their filesystem access.
  • Apply defense-in-depth controls such as disabling dangerous PHP functions and limiting script execution paths at the interpreter or pool configuration level.

How teams detect issues like this

Security teams can look for this class of issue and its symptoms using a combination of code-focused and behavior-focused approaches:

  • Static analysis and code review:
  • Flag patterns where indices are computed on a transformed string (e.g., lowercased, normalized) and then applied to the original string or a differently encoded representation.
  • Review FastCGI/CGI integration code for manual splitting of SCRIPT_NAME, SCRIPT_FILENAME, and PATH_INFO, especially in Unicode-aware services.
  • Look for use of APIs like ToLower, normalization functions, or decoding routines that precede critical routing decisions without consistent handling of string length and encoding.
  • Configuration and policy checks:
  • Audit server and FastCGI configurations for execution of scripts in directories that also host user uploads or other untrusted content.
  • Enforce policies that disallow treating writable directories as executable roots.
  • Runtime and traffic analysis:
  • Monitor logs for requests with unusual Unicode paths that contain .php or similar script extensions in non-standard positions.
  • Observe discrepancies between logged request URIs and script filenames reported in backend logs or error traces.
  • Automated tooling:
  • Incorporate SAST tools and linters that understand Unicode and string-transformation pitfalls into CI/CD pipelines.
  • Use dynamic scanning to send crafted Unicode paths through FastCGI endpoints and detect mismatches between expected and actual script execution.

Sources

SourceLink
github.comgithub.com/caddyserver/caddy/releases/tag/v2.11.1
github.comgithub.com/caddyserver/caddy/security/advisories/GHSA-5r3v-vc8m-m96g
github.comgithub.com/php/frankenphp/security/advisories/GHSA-g966-83w7-6w38

Frequently asked

questions

Yes. The vulnerable behavior is triggered through HTTP(S) requests, so an attacker who can reach the Caddy server can attempt to exploit it. However, the most severe outcomes (like code execution) usually require that the attacker can also influence files on disk, such as via an upload feature or writable directories.

Not necessarily. If file uploads or writable directories are exposed to unauthenticated users, then an unauthenticated attacker could potentially craft both the request paths and the uploaded content. In environments where uploads or file write capabilities are restricted to authenticated users, exploitation at the RCE level would typically require those privileges.

The core fix pattern is to ensure that all path parsing and splitting logic operates on a single, consistent representation of the path. Any transformation that may change string length (such as Unicode case folding) should be applied in a way that does not break index calculations—either by performing both detection and slicing on the same transformed string, or by avoiding index reuse across different representations. Additionally, avoid executing files from locations where untrusted content can be written.

To prevent related vulnerabilities, design path handling with explicit awareness of Unicode and encoding behavior, avoid mixing indices across transformed and original strings, and apply strict separation between executable script directories and writable content directories. Embed these rules into coding guidelines, code review checklists, and automated static analysis, and complement them with server and application configurations that minimize the attack surface for script execution.

Find out what's already
exploitable in your codebase.