-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## `WithRequestSplitPath` already rules out Unicode matches\n\nFrankenPHP is a PHP application server written in Go by [Kévin Dunglas](https://github.com/dunglas), the maintainer of Symfony's Mercure and a Symfony Core contributor. It embeds the PHP interpreter into a Caddy server module and dispatches HTTP requests into PHP through a CGI-like environment. The function that decides which file on disk a request runs lives in [`cgi.go`](https://github.com/php/frankenphp/blob/v1.12.3/cgi.go), at `splitCgiPath()`:\n\n```go\nfunc splitCgiPath(fc *frankenPHPContext) {\n path := fc.request.URL.Path\n splitPath := fc.splitPath\n\n if splitPath == nil {\n splitPath = []string{\".php\"}\n }\n\n if splitPos := splitPos(path, splitPath); splitPos > -1 {\n fc.docURI = path[:splitPos]\n fc.pathInfo = path[splitPos:]\n fc.scriptName = strings.TrimSuffix(path, fc.pathInfo)\n }\n fc.scriptFilename = sanitizedPathJoin(fc.documentRoot, fc.scriptName)\n fc.worker = workersByPath[fc.scriptFilename]\n}\n```\n\n`splitPos()` returns the byte index where `path` should be cut. Everything before becomes `SCRIPT_NAME` and resolves to a path on disk that PHP loads and executes. Everything after becomes `PATH_INFO`. The split entries (default `[\".php\"]`) are registered through `WithRequestSplitPath`, which is the canonical gate every Caddy site config goes through. Its body is short, and it states a precondition the rest of the code is allowed to rely on:\n\n```go\n// WithRequestSplitPath contains a list of split path strings.\n// Split paths can only contain ASCII characters.\n// Comparison is case-insensitive.\nfunc WithRequestSplitPath(splitPath []string) (RequestOption, error) {\n var b strings.Builder\n for i, split := range splitPath {\n b.Grow(len(split))\n for j := 0; j < len(split); j++ {\n c := split[j]\n if c >= utf8.RuneSelf {\n return nil, ErrInvalidSplitPath\n }\n if 'A' <= c && c <= 'Z' {\n b.WriteByte(c + 'a' - 'A')\n } else {\n b.WriteByte(c)\n }\n }\n splitPath[i] = b.String()\n b.Reset()\n }\n // ...\n}\n```\n\nTwo facts are now guaranteed before any path arrives at `splitPos`: every byte of every split entry is `< utf8.RuneSelf` (ASCII), and every alphabetic byte is lower-case. The contract of `splitPos` is to find an ASCII case-insensitive occurrence of those bytes inside the request path. A byte `>= utf8.RuneSelf` in `path` can never participate in a legitimate match, because the split entry it would match against is ASCII by construction.\n\nThat is the precondition `splitPos` is built on, and the precondition the January patch decided to handle anyway.\n\n## The January patch added a Unicode fallback to enforce an ASCII match\n\nCVE-2026-24895 was a length-expansion bug. The pre-January-2026 `splitPos` called `strings.ToLower(path)`, ran `strings.Index` on the lowercased copy, and returned the byte offset. Some Unicode code points expand when lowercased: `Ⱥ` (U+023A, two bytes in UTF-8) folds to `ⱥ` (U+2C65, three bytes). A path of `/ȺȺȺȺshell.php.txt.php` would lowercase to a longer string, the index found inside the longer string would no longer point at the same byte in the original, and the slice operation in `splitCgiPath` would route `payload.txt.php` as the script and execute the wrong file. AbdrrahimDahmani reported it. The GHSA was published February 12, 2026.\n\nThe fix shipped on January 26, 2026 as [commit `04fdc0c1`](https://github.com/php/frankenphp/commit/04fdc0c1e8fde94e2c1ad86217e962c88d27c53e), tagged in [v1.11.2](https://github.com/php/frankenphp/releases/tag/v1.11.2). It deleted the `strings.ToLower(path)` line, deleted the dependency on the lowercased copy, and rewrote the matcher as a byte loop:\n\n```go\nvar splitSearchNonASCII = search.New(language.Und, search.IgnoreCase)\n\nfunc splitPos(path string, splitPath []string) int {\n if len(splitPath) == 0 {\n return 0\n }\n pathLen := len(path)\n // We are sure that split strings are all ASCII-only and lower-case\n // because of validation and normalization in WithRequestSplitPath\n for _, split := range splitPath {\n splitLen := len(split)\n for i := 0; i < pathLen; i++ {\n if path[i] >= utf8.RuneSelf {\n if _, end := splitSearchNonASCII.IndexString(path, split); end > -1 {\n return end\n }\n break\n }\n if i+splitLen > pathLen {\n continue\n }\n match := true\n for j := 0; j < splitLen; j++ {\n c := path[i+j]\n if c >= utf8.RuneSelf {\n if _, end := splitSearchNonASCII.IndexString(path, split); end > -1 {\n return end\n }\n break\n }\n if 'A' <= c && c <= 'Z' {\n c += 'a' - 'A'\n }\n if c != split[j] {\n match = false\n break\n }\n }\n if match {\n return i + splitLen\n }\n }\n }\n return -1\n}\n```\n\nThe comment two lines into the function is the prosecution's first exhibit: the author wrote down, as a contract, that split strings are ASCII-only because `WithRequestSplitPath` validated them. Two blocks below that comment, on the same indentation level, the author called `search.New(language.Und, search.IgnoreCase)` to handle the case where `path[i]` is not ASCII.\n\n`golang.org/x/text/search` is the Unicode-correct collation library. `search.IgnoreCase` applies Unicode compatibility decomposition (NFKC) and full Unicode case folding before comparing. It is the right library for matching `\"München\"` against `\"MUNCHEN\"`. It is the wrong library for matching against a four-byte ASCII string the same function just declared cannot contain non-ASCII bytes. The fallback was answering a question the precondition had already answered: there is no legitimate Unicode case in which a non-ASCII byte in the request path is part of a match against the ASCII-validated split entry. The correct answer was always \"not a match.\" The fallback chose \"ask the Unicode library.\"\n\nThe Unicode library was happy to answer.\n\n## Flaw 1: the inner loop breaks without resetting `match`\n\nKC1zs4 reported the first flaw in [GHSA-3g8v-8r37-cgjm](https://github.com/php/frankenphp/security/advisories/GHSA-3g8v-8r37-cgjm). The inner `for j` loop walks the split string against the path starting at offset `i`. When a byte of the path is non-ASCII, the loop hits the fallback `splitSearchNonASCII.IndexString(path, split)`. When that fallback returns `-1`, the loop `break`s. It does not set `match = false` first.\n\nThe outer code then evaluates `if match { return i + splitLen }` with `match` still holding its initial value, `true`. The function returns an offset as if `.php` had been matched there. The split that follows treats whatever bytes sit at that offset as the script extension.\n\nConcrete walk against `/PoC-match-unset.¡.txt`, which is 23 bytes (the `¡` U+00A1 is the two-byte UTF-8 sequence `0xC2 0xA1`):\n\n- Outer loop: `i` walks 0..15 (all ASCII, no first-byte match for `.`).\n- `i = 16`: `path[16] = '.'`. Inner `j` loop starts.\n - `j = 0`: `c = '.'`, `c == split[0]`. Continue.\n - `j = 1`: `c = path[17] = 0xC2`. `c >= utf8.RuneSelf`. Hit fallback. `IndexString(path, \".php\")` finds no `.php` (literal or Unicode-equivalent) anywhere in the path. Returns `-1`. Inner `break` runs. `match` was never set to `false`.\n- Outer code: `if match { return i + splitLen }`. Returns `16 + 4 = 20`.\n\nThe advisory's PoC output confirms it:\n\n```text\n/PoC-match-unset.¡.txt : 20\n```\n\n`splitCgiPath` then slices `path[:20] = \"/PoC-match-unset.¡.\"` (17 + 2 + 1 = 20 bytes, through the second dot). `pathInfo = \"txt\"`. `scriptName = \"/PoC-match-unset.¡.\"`. `scriptFilename = \"/PoC-match-unset.¡.\"`. PHP loads and executes the file at that path. The file's actual extension is the trailing `.`, not `.php`. PHP runs whatever PHP source is inside it.\n\nThe inner `break` reasoned about itself as \"abandon the current starting offset and try the next one.\" It was sitting underneath a closure that reasoned about itself as \"abandon the inner loop with a victory.\"\n\n## Flaw 2: `search.IgnoreCase` folds `𝗽𝗵𝗽` onto `.php`\n\nThe second flaw, originally filed as GHSA-v4h7-cj44-8fc8 and consolidated into the same advisory, exercises the outer fallback. When the very first byte under inspection is non-ASCII, the outer `if path[i] >= utf8.RuneSelf { ... }` branch runs and the request immediately reaches `splitSearchNonASCII.IndexString(path, \".php\")`. This is the path-level Unicode search. `search.New(language.Und, search.IgnoreCase)` does NFKC decomposition and full Unicode case folding. Many code points fold onto ASCII `.`, `p`, `h`:\n\n- `U+FE52` `﹒` (small full stop) folds to `.`\n- `U+FF0E` `.` (fullwidth full stop) folds to `.`\n- `U+FF50` `p` (fullwidth lowercase p) folds to `p`\n- `U+24DF` `ⓟ`, `U+24DD` `ⓗ` (circled) fold to `p`, `h`\n- `U+1D5FD` `𝗽` (mathematical sans-serif bold p) folds to `p`\n- `U+1D4C5` `𝓅` (mathematical script p) folds to `p`\n\nThe advisory's own reproducer covers every one of them:\n\n```text\n/shell﹒php : 12\n/shell.php : 12\n/shell.php : 12\n/shell.php : 12\n/shell.ⓟⓗⓟ : 16\n/shell.𝗽𝗵𝗽 : 19\n/shell.𝓅𝒽𝓅 : 19\n/shell.ⓟⓗⓟ.anything-after-payload.php : 16\n```\n\nEach row is `splitPos` returning a position as if a literal `.php` lived at that byte offset. None of them are `.php` files. They are Unicode-equivalent renderings of the substring `.php`, baked into URL paths an attacker controls. The end-of-match offset goes back up the stack to `splitCgiPath`, which slices the original `path` there, and `sanitizedPathJoin(documentRoot, scriptName)` resolves to a file on disk that ends in `.𝗽𝗵𝗽`. The attacker uploaded that file. The file's contents are PHP. PHP runs.\n\nThe end-to-end demonstration from the advisory, against `dunglas/frankenphp:latest` before May 15:\n\n```bash\ndocker run --rm -d --name frankenphp-poc \\\n -p 18080:8080 \\\n -v \"$(pwd)/Caddyfile:/etc/frankenphp/Caddyfile:ro\" \\\n -v \"$(pwd)/public:/app/public\" \\\n dunglas/frankenphp:latest\n\n# Both files are real files on disk:\n# /app/public/poc-match-unset.¡. (contents: )\n# /app/public/poc-search-norm.𝗽𝗵𝗽 (contents: )\n\n# Baseline: a .txt URL is not routed as PHP.\ncurl -i --path-as-is \"http://127.0.0.1:18080/poc-match-unset.txt/trigger\"\n\n# Flaw 1: the Unicode byte after a dot stalls match=true.\ncurl -i --path-as-is \"http://127.0.0.1:18080/poc-match-unset.%C2%A1.txt/trigger\"\n# Response body: marker=flaw1\n\n# Flaw 2: a math-bold .php folds onto the literal under search.IgnoreCase.\ncurl -i --path-as-is \\\n \"http://127.0.0.1:18080/poc-search-norm.%F0%9D%97%BD%F0%9D%97%B5%F0%9D%97%BD.anything-after-payload.php/trigger\"\n# Response body: marker=flaw2\n```\n\nThe CVSS vector is `AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H`, scored 8.1. The `AC:H` is the precondition that the attacker can place a file with a non-ASCII byte in its name inside FrankenPHP's document root. Uploads endpoints, package mirrors, user-content stores, anywhere a tenant chooses their own filename, all satisfy that precondition. WAFs that strip non-ASCII bytes from URL paths satisfy it negatively; the bytes are already in `path` by the time `splitPos` reads them.\n\n## The May patch deletes the January patch\n\n[Commit `2d0f4803`](https://github.com/php/frankenphp/commit/2d0f480329a02571d6f635dad9fdb066e1a11e81), released as [v1.12.3](https://github.com/php/frankenphp/releases/tag/v1.12.3) on May 15, 2026, removes the `golang.org/x/text/search` import, deletes the `splitSearchNonASCII` package variable, and rewrites the matching loop without any Unicode-library fallback:\n\n```diff\n import (\n \"unsafe\"\n\n \"github.com/dunglas/frankenphp/internal/phpheaders\"\n- \"golang.org/x/text/language\"\n- \"golang.org/x/text/search\"\n )\n\n-var splitSearchNonASCII = search.New(language.Und, search.IgnoreCase)\n-\n func splitPos(path string, splitPath []string) int {\n if len(splitPath) == 0 {\n return 0\n }\n pathLen := len(path)\n- // We are sure that split strings are all ASCII-only and lower-case because of validation and normalization in WithRequestSplitPath\n for _, split := range splitPath {\n splitLen := len(split)\n+ if splitLen == 0 || splitLen > pathLen {\n+ continue\n+ }\n- for i := 0; i < pathLen; i++ {\n- if path[i] >= utf8.RuneSelf {\n- if _, end := splitSearchNonASCII.IndexString(path, split); end > -1 {\n- return end\n- }\n- break\n- }\n- if i+splitLen > pathLen {\n- continue\n- }\n+ for i := 0; i <= pathLen-splitLen; i++ {\n match := true\n for j := 0; j < splitLen; j++ {\n c := path[i+j]\n-\n if c >= utf8.RuneSelf {\n- if _, end := splitSearchNonASCII.IndexString(path, split); end > -1 {\n- return end\n- }\n+ match = false\n break\n }\n```\n\nThe new behavior is the only behavior the precondition ever permitted: any byte `>= utf8.RuneSelf` in the path is a non-match against the current split entry, full stop. The comment that used to apologize for the fallback is replaced with a comment that explains why the fallback was always wrong:\n\n```go\n// Matching is strictly ASCII case-insensitive. Bytes >= utf8.RuneSelf\n// in path never match any split entry: split strings are validated\n// ASCII-only and lower-cased in WithRequestSplitPath, so any Unicode\n// equivalence (e.g. fullwidth or mathematical letters folding to ASCII)\n// would let an attacker upload a file whose name contains such code\n// points and have it served as PHP. See GHSA-3g8v-8r37-cgjm and\n// GHSA-v4h7-cj44-8fc8.\n```\n\nThe patch ships with eleven regression tests pinning the new behavior, named bluntly. `non-ascii byte after dot must not match` pins flaw 1. `circled php must not match`, `mathematical sans-serif bold php must not match`, `fullwidth p in extension must not match` pin flaw 2. The author who shipped the January code now ships the tests that would have caught it.\n\n## `splitPos` has produced two Unicode RCEs in four months\n\nThe blog catalog has a name for components that fail by class: design-debt-driver. The thesis is that some functions produce CVEs of the same shape across years because the design substrate is fertile for one specific bug family, and each patch closes the instance without closing the substrate. FrankenPHP's `splitPos` qualifies on the first CVE pair. CVE-2026-24895 (length-expansion under `strings.ToLower`) and CVE-2026-45062 (Unicode equivalence under `search.IgnoreCase`) are the same class: a Unicode-aware string operation imported into a context whose precondition was always \"bytes, ASCII-only, byte offsets, no Unicode semantics, please.\" Both yielded RCE in the FrankenPHP process. Both were fixed by deleting the Unicode-aware operation and walking the bytes directly.\n\nThe pattern even names the failure mode of the maintenance loop: the substrate does not fix itself when an instance is patched. The January patch is the canonical case. The author understood the previous bug well enough to remove `strings.ToLower(path)` and rewrite the matcher byte by byte. In the same diff, the author added a Unicode-equivalence library to handle the case where the precondition's invariant was violated. The instance was closed. The substrate was not. The substrate produced the next instance 109 days later, by way of the very code the patch added.\n\nKC1zs4 filed two GHSAs against `splitPos` (one for each flaw), and GitHub consolidated them after recognizing they were two flaws in the same eleven lines. One researcher, looking at one function for one afternoon, found two distinct RCE paths through the patch that was supposed to make the function safe.\n\n## The fix that took 109 days was not additive\n\nThe post-May-15 `splitPos` is a single tight byte loop with no library calls in the hot path. It does what `WithRequestSplitPath` told it the inputs would always allow it to do. The whole patch reads as a maintainer accepting that the previous fix had reached for the wrong tool, and that the right tool was no tool. There is no Unicode-aware fallback. There is no path under which a non-ASCII byte interacts with the split entry. There is no library call between the request URL and the disk path PHP loads.\n\nThere are also operators sitting on FrankenPHP 1.11.2 through 1.12.2 right now, because that range was the recommended fix for the previous RCE and the upgrade-on-CVE habit converged people into the window. Every one of them is carrying the fallback the May advisory removed.\n\nPoC: [GHSA-3g8v-8r37-cgjm](https://github.com/advisories/GHSA-3g8v-8r37-cgjm)","closing_line":"splitPos is now what WithRequestSplitPath always said it was: byte-level, ASCII-only, lower-cased. The 109-day patch that got there was the patch that deleted the previous patch.","hook_md":"FrankenPHP closed CVE-2026-24895 on January 26, 2026, a path-confusion RCE where `strings.ToLower(path)` expanded `Ⱥ` from two UTF-8 bytes to three and the index it returned no longer pointed at the same byte in the original URL. The patch rewrote `splitPos()` in `cgi.go` to walk the path byte by byte with an ASCII fast path, and added a Unicode-aware fallback for any non-ASCII byte using `golang.org/x/text/search` with `search.IgnoreCase`. The advisory on May 15, 2026 closes CVE-2026-45062 by deleting that fallback. Two distinct flaws in those eleven lines, one a stale control-flow flag, one a Unicode-equivalence fold of `𝗽𝗵𝗽` onto `.php`, both reported against the same function by the same researcher, both yielding RCE through attacker-uploadable `.txt` files routed as PHP. The fallback that closed CVE-2026-24895 in January is the code path that opens CVE-2026-45062 in May.","post_id":655,"slug":"frankenphp-cve-2026-45062-january-patch-is-may-rce","title":"CVE-2026-45062: FrankenPHP's January Patch For The Last Unicode RCE Is The May Unicode RCE","type":"initial","unreadable_sentence":"The fallback that closed CVE-2026-24895 in January is the code path that opens CVE-2026-45062 in May."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCavN+ZAAKCRDeZjl4jgkQ JstlAP0Ukk2cymEc8GjGAOFuB7stpCwuK/1XYDUWQEqlELDi0wD+NRaXS5iptRm4 +QxATl+1eqTocT7wa58FJ1LZI6xkzAs= =yC9s -----END PGP SIGNATURE-----