Summary
View::e(), FlightPHP's built-in output escaping helper, calls htmlentities($str) without specifying the $flags parameter. On PHP 7.4 and 8.0, the default flags value is ENT_COMPAT, which escapes double quotes but does NOT escape single quotes ('). This allows an attacker to break out of single-quoted HTML attributes and inject arbitrary JavaScript.
FlightPHP's composer.json declares "php": ">=7.4", so PHP 7.4 and 8.0 are officially supported runtimes where this vulnerability is exploitable.
Root Cause
flight/template/View.php line 192:
public function e(string $str): string
{
$value = \htmlentities($str); // no flags, no charset
echo $value;
return $value;
}
The htmlentities() function signature is htmlentities(string $string, int $flags = ENT_QUOTES | ENT_SUBSTITUTE, ...) on PHP 8.1+, but on PHP 7.4 and 8.0 the default is ENT_COMPAT. ENT_COMPAT converts double quotes but leaves single quotes untouched.
PoC
<input type='text' value='<?= $this->e($msg) ?>'>
GET /?msg=%27+onmouseover%3Dalert(1)+x%3D%27
Suggested Fix
Explicitly pass ENT_QUOTES | ENT_SUBSTITUTE and 'UTF-8' to htmlentities(), making the escaping behavior consistent across all supported PHP versions:
// BEFORE (vulnerable on PHP < 8.1)
$value = \htmlentities($str);
// AFTER (safe on all PHP versions)
$value = \htmlentities($str, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
Summary
View::e(), FlightPHP's built-in output escaping helper, callshtmlentities($str)without specifying the$flagsparameter. On PHP 7.4 and 8.0, the default flags value isENT_COMPAT, which escapes double quotes but does NOT escape single quotes ('). This allows an attacker to break out of single-quoted HTML attributes and inject arbitrary JavaScript.FlightPHP's
composer.jsondeclares"php": ">=7.4", so PHP 7.4 and 8.0 are officially supported runtimes where this vulnerability is exploitable.Root Cause
flight/template/View.phpline 192:The
htmlentities()function signature ishtmlentities(string $string, int $flags = ENT_QUOTES | ENT_SUBSTITUTE, ...)on PHP 8.1+, but on PHP 7.4 and 8.0 the default isENT_COMPAT.ENT_COMPATconverts double quotes but leaves single quotes untouched.PoC
Suggested Fix
Explicitly pass
ENT_QUOTES | ENT_SUBSTITUTEand'UTF-8'tohtmlentities(), making the escaping behavior consistent across all supported PHP versions: