The vulnerability exists in the splitPos function located in the cgi.go file of the FrankenPHP project. The function is responsible for splitting the request path to determine the script to be executed. The vulnerability is caused by improper handling of Unicode characters in the path. The original implementation used golang.org/x/text/search with search.IgnoreCase, which led to two distinct flaws.
First, a control-flow flaw allowed a stale match variable to cause a false positive when a non-ASCII character was present in the path. This would cause the server to misinterpret the path and execute a file that was not intended to be executed as a PHP script.
Second, the search.IgnoreCase option performed Unicode equivalence matching, which is broader than simple ASCII case-insensitivity. This allowed attackers to use various Unicode characters that are visually similar to the characters in .php to craft a filename that would be incorrectly identified as a PHP script. For example, a file named shell.php (using a full-width 'p') would be treated as a PHP file.
An attacker who can upload a file to a server running a vulnerable version of FrankenPHP could exploit this vulnerability by crafting a URL with a specially crafted path. This would lead to the execution of the uploaded file as a PHP script, resulting in remote code execution.
The patch addresses these issues by removing the dependency on golang.org/x/text/search and replacing the logic with a strict ASCII byte-level comparison. This ensures that only legitimate .php files are executed as PHP scripts.