8.9high
Caddy: Unicode case-folding length expansion causes incorrect split_path index (SCRIPT_NAME/PATH_INFO confusion) in FastCGI transport
- Severity
- 8.9high CVSS:4.0 by GitHub_M
- Exploit likelihood
- 0.63% (higher than 51% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-5r3v-vc8m-m96gGO-2026-4536
Description
Caddy is an extensible server platform that uses TLS by default. Prior to version 2.11.1, Caddy's FastCGI path splitting logic computes the split index on a lowercased copy of the request path and then uses that byte index to slice the original path. This is unsafe for Unicode because `strings.ToLower()` can change UTF-8 byte length for some characters. As a result, Caddy can derive an incorrect `SCRIPT_NAME`/`SCRIPT_FILENAME` and `PATH_INFO`, potentially causing a request that contains `.php` to execute a different on-disk file than intended (path confusion). In setups where an attacker can control file contents (e.g., upload features), this can lead to unintended PHP execution of non-.php files (potential RCE depending on deployment). Version 2.11.1 fixes the issue.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| caddyserver caddy | < 2.11.1, before 2.11.1 | CVE List, NVD |
| github.com/caddyserver/caddy/v2 (Go) | before 2.11.1 | GitHub Advisory Database, Go Vulnerability Database |
All scores
| GitHub_M | 8.9high CVSS:4.0 | CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:P |
| GitHub | high CVSS:4.0 | CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:P |
| NVD | 9.8critical CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H |
Classification
What each source says
CVE List
Caddy is an extensible server platform that uses TLS by default. Prior to version 2.11.1, Caddy's FastCGI path splitting logic computes the split index on a lowercased copy of the request path and then uses that byte index to slice the original path. This is unsafe for Unicode because `strings.ToLower()` can change UTF-8 byte length for some characters. As a result, Caddy can derive an incorrect `SCRIPT_NAME`/`SCRIPT_FILENAME` and `PATH_INFO`, potentially causing a request that contains `.php` to execute a different on-disk file than intended (path confusion). In setups where an attacker can control file contents (e.g., upload features), this can lead to unintended PHP execution of non-.php files (potential RCE depending on deployment). Version 2.11.1 fixes the issue.
GitHub Advisory Database
Summary
Caddy's FastCGI path splitting logic computes the split index on a lowercased copy of the request path and then uses that byte index to slice the original path. This is unsafe for Unicode because strings.ToLower() can change UTF-8 byte length for some characters. As a result, Caddy can derive an incorrect SCRIPT_NAME/SCRIPT_FILENAME and PATH_INFO, potentially causing a request that contains .php to execute a different on-disk file than intended (path confusion). In setups where an attacker can control file contents (e.g., upload features), this can lead to unintended PHP execution of non-.php files (potential RCE depending on deployment).
Details
The issue is in github.com/caddyserver/caddy/modules/caddyhttp/fastcgi.Trasnport.splitPos() (and the subsequent slicing in buildEnv()):
lowerPath := strings.ToLower(path)
idx := strings.Index(lowerPath, strings.ToLower(split))
return idx + len(split)
The returned index is computed in the byte space of lowerPath, but buildEnv() applies it to the original path:
docURI = path[:splitPos]pathInfo = path[splitPos:]scriptName = strings.TrimSuffix(path, fc.pathInfo)scriptFilename = caddyhttp.SanitizedPathJoin(fc.documentRoot, fc.scriptName)
This assumes lowerPath and path have identical byte lengths and identical byte offsets, which is not true for some Unicode case mappings. Certain characters expand when lowercased (UTF-8 byte length increases), shifting the computed index. This creates a mismatch where .php is found in the lowercased string at an offset that does not correspond to the same position in the original string, causing the split point to land later/earlier than intended.
PoC
Create a small Go program that reproduces Caddy's splitPos() behavior (compute the .php split point on a lowercased path, then use that byte index on the original path):
- Save this as
poc.go:
package main
import (
"fmt"
"strings"
)
func splitPos(path string, split string) int {
lowerPath := strings.ToLower(path)
idx := strings.Index(lowerPath, strings.ToLower(split))
if idx < 0 {
return -1
}
return idx + len(split)
}
func main() {
// U+023A: Ⱥ (UTF-8: C8 BA). Lowercase is ⱥ (UTF-8: E2 B1 A5), longer in bytes.
path := "/ȺȺȺȺshell.php.txt.php"
split := ".php"
pos := splitPos(path, split)
fmt.Printf("orig bytes=%d\n", len(path))
fmt.Printf("lower bytes=%d\n", len(strings.ToLower(path)))
fmt.Printf("splitPos=%d\n", pos)
fmt.Printf("orig[:pos]=%q\n", path[:pos])
fmt.Printf("orig[pos:]=%q\n", path[pos:])
// Expected split: right after the first ".php" in the original string
want := strings.Index(path, split) + len(split)
fmt.Printf("expected splitPos=%d\n", want)
fmt.Printf("expected orig[:]=%q\n", path[:want])
}
- Run it:
go run poc.go
Output on my side:
orig bytes=26
lower bytes=30
splitPos=22
orig[:pos]="/ȺȺȺȺshell.php.txt"
orig[pos:]=".php"
expected splitPos=18
expected orig[:]="/ȺȺȺȺshell.php"
Expected split is right after the first .php (/ȺȺȺȺshell.php). Instead, the computed split lands later and cuts the original path after shell.php.txt, leaving .php as the remainder.
Impact
Security boundary bypass/path confusion in script resolution.
In typical deployments, .php extension boundaries are relied on to decide what is executed by PHP. This bug can cause Caddy/FPM to execute a different file than intended by confusing SCRIPT_NAME/SCRIPT_FILENAME. If an attacker can place attacker-controlled content into a file that can be resolved as SCRIPT_FILENAME (common in web apps with uploads or writable directories), this can lead to unintended PHP execution of non-.php files and potentially remote code execution. Severity depends on deployment and presence of attacker-controlled file writes, but the primitive itself is remotely triggerable via crafted URLs.
This vulnerability was initially reported to FrankenPHP (https://github.com/php/frankenphp/security/advisories/GHSA-g966-83w7-6w38) by @AbdrrahimDahmani. The affected code has been copied/adapted from Caddy, which, according to research, is also affected.
The patch is a port of the FrankenPHP patch.
Go Vulnerability Database
Unicode case-folding causes incorrect split_path index in github.com/caddyserver/caddy/v2
NVD (es)
Caddy es una plataforma de servidor extensible que utiliza TLS por defecto. Antes de la versión 2.11.1, la lógica de división de rutas FastCGI de Caddy calcula el índice de división en una copia en minúsculas de la ruta de la solicitud y luego utiliza ese índice de bytes para segmentar la ruta original. Esto no es seguro para Unicode porque `strings.ToLower()` puede cambiar la longitud de bytes UTF-8 para algunos caracteres. Como resultado, Caddy puede derivar un `SCRIPT_NAME`/`SCRIPT_FILENAME` y `PATH_INFO` incorrectos, lo que podría causar que una solicitud que contiene .php ejecute un archivo en disco diferente al previsto (confusión de rutas). En configuraciones donde un atacante puede controlar el contenido de los archivos (por ejemplo, funciones de carga), esto puede llevar a la ejecución no intencionada de PHP de archivos que no son .php (RCE potencial dependiendo de la implementación). La versión 2.11.1 corrige el problema.
References
| https://github.com/caddyserver/caddy/security/advisories/GHSA-5r3v-vc8m-m96g | advisory, exploit, vendor-advisory, web | |
| https://github.com/php/frankenphp/security/advisories/GHSA-g966-83w7-6w38 | third-party-advisory, web | |
| https://github.com/caddyserver/caddy/releases/tag/v2.11.1 | release-notes, web | |
| https://nvd.nist.gov/vuln/detail/CVE-2026-27590 | advisory | |
| https://github.com/caddyserver/caddy | package | |
| https://pkg.go.dev/vuln/GO-2026-4536 | web | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-27590 changed 2026-02-27 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-5r3v-vc8m-m96g changed 2026-02-27 | CC-BY-4.0 |
| Go Vulnerability Database | GO-2026-4536 changed 2026-02-26 | CC-BY-4.0 |
| NVD | CVE-2026-27590 changed 2026-06-17 | Public domain |