/

CVE-2026-45062

Severity:

HIGH RISK

(8.1)

Path Parsing Flaws (CWE-20) in FrankenPHP CGI Router

CVE-2026-45062

Deferred

Vulnerability type

Category:

Input Validation and Path Parsing

CWE:

CWE-20, CWE-176, CWE-178

Impact:

Remote Code Execution via Misrouted Script Handling

Severity:

HIGH RISK

(8.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

FrankenPHP contains a path parsing flaw where the splitPos() function mishandles non-ASCII bytes when performing case-insensitive matching, allowing non-.php files to be treated as PHP scripts.

In deployments where attackers can upload or otherwise place files on the server, they can craft URLs that trigger this confusion and potentially achieve remote code execution.

Affected context

This vulnerability affects FrankenPHP deployments using the CGI-style routing logic implemented in cgi.go, specifically versions 1.11.2 through 1.12.2.

It appears in environments where:

  • FrankenPHP inspects request paths to decide whether a resource should be executed as PHP or served as static content
  • Non-ASCII bytes in URLs are accepted and passed through to the router
  • Users can upload or otherwise influence files that are later served by FrankenPHP (such as media uploads, document storage, or user-generated content)

The issue is tied to how the server determines ".php" extensions under case-insensitive matching, so it is most risky when extension-based routing is relied upon for security.

Exploit preconditions

  • Attack surface: HTTP(S) interface exposed by FrankenPHP, including any endpoints that accept or serve user-controlled files.
  • Required access: Ability to upload or place arbitrary content into files that FrankenPHP will serve (e.g., authenticated uploads, multi-tenant storage, misconfigured public write directories).
  • Trigger point: An HTTP request whose path contains at least one non-ASCII byte and matches specific patterns that confuse splitPos() into misclassifying the target file as a PHP script.
  • Why exploitation is possible: The splitPos() function uses golang.org/x/text/search with search.IgnoreCase in a way that does not account for non-ASCII normalization and comparison semantics, causing incorrect detection of the .php suffix and leading the server to execute content that should be treated as static.

Why this happens

The underlying issue is improper input validation and canonicalization in the path parsing logic that decides which requests are routed to the PHP interpreter.

The splitPos() function relies on a case-insensitive search over raw request paths and assumes ASCII-oriented behavior, but non-ASCII bytes interact with golang.org/x/text/search in ways that the code does not anticipate.

This misalignment between the comparison model and the actual byte-level path leads to incorrect identification of the .php extension, mapping primarily to CWE-20: Improper Input Validation, with aspects of CWE-176: Improper Handling of Unicode Encoding and CWE-178: Improper Handling of Case Sensitivity.

Abstractly, the pattern is: security-sensitive decisions (script vs static) are made on non-normalized, locale-sensitive string operations instead of strict, canonical extension checks on a validated path representation.

Potential impact

  • Non-PHP files may be incorrectly treated and executed as PHP scripts.
  • Attackers who can control file contents may execute arbitrary PHP code on the server.
  • Compromise of application data, including reading or modifying sensitive information.
  • Escalation from a simple file upload capability to full remote code execution.
  • Potential pivot to broader system compromise depending on PHP configuration and host hardening.

General mitigation guidance

Mitigation should focus on making path and extension handling deterministic, byte-safe, and independent of locale or complex case-folding rules.

Useful patterns include:

  • Performing extension checks on a canonical, normalized path using simple, ASCII-aware comparisons rather than locale-dependent search utilities.
  • Decoupling routing from raw user input by mapping requests to an internal, sanitized resource representation before deciding execution behavior.
  • Treating all user-uploaded or user-controlled files as non-executable by default, and segregating upload directories from script directories.
  • Applying least-privilege principles to the PHP runtime (e.g., restricted file system access and disabled dangerous PHP functions) to reduce impact if misclassification occurs.
  • Using defense-in-depth controls such as web server rules that explicitly prevent execution from upload paths, regardless of application behavior.

How teams detect issues like this

Detection can rely on a combination of code-centric and behavior-centric approaches:

  • Static analysis rules that flag security decisions based on complex, locale-aware or Unicode-sensitive string APIs instead of simple, canonical comparisons for extensions.
  • Code review patterns focusing on routing logic and file serving paths, verifying that .php detection is based on normalized, byte-level checks and that Unicode and case handling are consistent.
  • Automated tests that exercise routing with paths containing non-ASCII bytes, mixed case extensions, and unusual encodings, verifying that only intended files are executed as PHP.
  • Runtime monitoring and web application firewalls that look for suspicious access patterns to uploaded content, especially requests with unusual encodings that cause non-PHP files to be treated as dynamic.
  • Integration of automated security review tools into CI/CD pipelines to highlight changes to URL parsing, routing, and upload handling logic.

Sources

SourceLink
github.comgithub.com/php/frankenphp/releases/tag/v1.12.3
github.comgithub.com/php/frankenphp/security/advisories/GHSA-3g8v-8r37-cgjm

Frequently asked

questions

Exploitability depends heavily on whether the application allows users to upload or influence files that FrankenPHP later serves.

In environments with user uploads mapped under the same domain and routing rules, the vulnerability can be highly impactful and may lead to remote code execution.

Not necessarily.

If any unauthenticated endpoint permits file uploads or user-controlled file placement in a path served by FrankenPHP, exploitation could be anonymous; otherwise, attackers generally need whatever level of access is required to store files on the server.

The most robust fix is to remove dependence on complex, locale-aware search for extension detection and instead perform strict, canonical path normalization followed by simple, deterministic extension checks.

Additionally, ensure that upload directories are treated as data-only, non-executable locations by both the application and the fronting web server.

Future code should normalize and validate all paths before making routing decisions, avoid using Unicode- or locale-sensitive APIs for security-critical checks, and enforce clear separation between executable scripts and user-controlled content.

Incorporating security-focused code review for URL parsing, file resolution, and upload handling logic, backed by automated tests for edge cases (non-ASCII bytes, encodings, case variants), helps prevent regressions.

Find out what's already
exploitable in your codebase.