Visitar URL original
Stored/Reflected XSS via `View::e()` on < PHP 8.1 · Advisory · flightphp/core · GitHub
Skip to content

Stored/Reflected XSS via `View::e()` on < PHP 8.1

High
n0nag0n published GHSA-r8g9-m376-w889 Sep 4, 2026

Package

composer flightphp/core (Composer)

Affected versions

< 3.19.3

Patched versions

3.19.3

Description

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

  • Vulnerable Part
<input type='text' value='<?= $this->e($msg) ?>'>
  • Exploitation
GET /?msg=%27+onmouseover%3Dalert(1)+x%3D%27
image

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');

Severity

High

CVE ID

No known CVE

Weaknesses

Improper Neutralization of Input During Web Page Generation

The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. Learn more on MITRE.

Credits