Summary
Bypass XSS sanitizer using the javascript protocol and special characters
Product: Phpspreadsheet
Version: version 3.6.0
CWE-ID: CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
CVSS vector v.3.1: 5.4 (AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N)
CVSS vector v.4.0: 4.8 (AV:N/AC:L/AT:N/PR:L/UI:A/VC:L/VI:L/VA:N/SC:L/SI:L/SA:N)
Description: an attacker can use special characters, so that the library processes the javascript protocol with special characters and generates an HTML link
Impact: executing arbitrary JavaScript code in the browser
Vulnerable component: class PhpOffice\PhpSpreadsheet\Writer\Html, method generateRow
Exploitation conditions: a user viewing a specially generated Excel file
Mitigation: additional sanitization of special characters in a string
Researcher: Aleksey Solovev (Positive Technologies)
Research
The researcher discovered zero-day vulnerability Bypass XSS sanitizer using the javascript protocol and special characters in Phpspreadsheet.
The following code is written on the server, which translates the XLSX file into a HTML representation and displays it in the response.
Listing 6. Source code on the server
<?php
require __DIR__ . '/vendor/autoload.php';
$inputFileName = './doc/Book1.xlsx';
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($inputFileName);
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Html($spreadsheet);
print($writer->generateHTMLAll());
An attacker can use special characters so that this library processes the javascript protocol with special characters and generates a HTML link.
The Excel file is unpacked and a hyperlink in the file is inserted into the xl/worksheets/sheet1.xml file.
Figure 11. Using the javascript protocol with special characters
Some payloads help bypass the security system and carry out a XSS attack.
Listing 7. HTML form that demonstrates the exploitation of the XSS vulnerability
jav	ascript:alert()
jav
ascript:alert()
jav
ascript:alert()
It's clear that the javascript protocol with special characters is used.
Figure 12. Using the javascript protocol with special characters
Due to the special characters, the execution stream ends up on line 1543, and the link is built in HTML form with the javascript protocol.
Figure 13. Executing arbitrary JavaScript code
Credit
This vulnerability was discovered by Aleksey Solovev (Positive Technologies)
Impact
Untrusted input is rendered as active markup in a victim's browser, which can run script in their session. Typical impact: session or credential theft, and actions taken as the user.
CVE-2024-56412 has a CVSS score of 5.4 (Medium). The vector is network-reachable, low privileges required, and user interaction required. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (3.7.0, 1.29.7, 2.1.6, 2.3.5); upgrading removes the vulnerable code path.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Remediation advice
phpoffice/phpspreadsheet to 3.7.0 or later; phpoffice/phpspreadsheet to 1.29.7 or later; phpoffice/phpspreadsheet to 2.1.6 or later; phpoffice/phpspreadsheet to 2.3.5 or later
Kodem Kai can prioritize this vulnerability in your dependency tree and generate a fix recommendation.
Frequently Asked Questions
- What is CVE-2024-56412? CVE-2024-56412 is a medium-severity cross-site scripting (XSS) vulnerability in phpoffice/phpspreadsheet (composer), affecting versions >= 3.0.0, < 3.7.0. It is fixed in 3.7.0, 1.29.7, 2.1.6, 2.3.5. Untrusted input is rendered as active markup in a victim's browser, which can run script in their session.
- How severe is CVE-2024-56412? CVE-2024-56412 has a CVSS score of 5.4 (Medium). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
- Which packages are affected by CVE-2024-56412?
phpoffice/phpspreadsheet(composer) (versions >= 3.0.0, < 3.7.0)phpoffice/phpexcel(composer) (versions <= 1.8.2)
- Is there a fix for CVE-2024-56412? Yes. CVE-2024-56412 is fixed in 3.7.0, 1.29.7, 2.1.6, 2.3.5. Upgrade to this version or later.
- Is CVE-2024-56412 exploitable, and should I be worried? Whether CVE-2024-56412 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether CVE-2024-56412 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix CVE-2024-56412?
- Upgrade
phpoffice/phpspreadsheetto 3.7.0 or later - Upgrade
phpoffice/phpspreadsheetto 1.29.7 or later - Upgrade
phpoffice/phpspreadsheetto 2.1.6 or later - Upgrade
phpoffice/phpspreadsheetto 2.3.5 or later
- Upgrade