CVE-2024-45046: PhpSpreadsheet HTML writer is vulnerable to Cross-Site Scripting via style information
Summary
\PhpOffice\PhpSpreadsheet\Writer\Html doesn't sanitize spreadsheet styling information such as font names, allowing an attacker to inject arbitrary JavaScript on the page.
PoC
Example target script:
<?php
require 'vendor/autoload.php';
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader("Xlsx"); $spreadsheet = $reader->load(DIR . '/book.xlsx');
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Html($spreadsheet); print($writer->generateHTMLAll());
Save this file in the same directory: book.xlsx
Open index.php in a web browser. An alert should be displayed.
Impact
Full takeover of the session of users viewing spreadsheet files as HTML.
Other sources
PHPSpreadsheet is a pure PHP library for reading and writing spreadsheet files. In affected versions \PhpOffice\PhpSpreadsheet\Writer\Html doesn't sanitize spreadsheet styling information such as font names, allowing an attacker to inject arbitrary JavaScript on the page. As a result an attacker may used a crafted spreadsheet to fully takeover a session of a user viewing spreadsheet files as HTML. This issue has been addressed in release version 2.1.0. All users are advised to upgrade. There are no known workarounds for this vulnerability.
— MITRE
Affected Software
Remediation
Patch Available
Event History
Frequently Asked Questions
What is the severity of CVE-2024-45046?
CVE-2024-45046 has a high severity rating due to the potential for arbitrary JavaScript injection.
How do I fix CVE-2024-45046?
To fix CVE-2024-45046, upgrade to PhpSpreadsheet version 1.29.1 or 2.1.0.
What type of vulnerability is CVE-2024-45046?
CVE-2024-45046 is a Cross-Site Scripting (XSS) vulnerability caused by improper sanitization of spreadsheet styling information.
Who is affected by CVE-2024-45046?
CVE-2024-45046 affects users of the PhpSpreadsheet library versions prior to 1.29.1 and between 2.0.0 and 2.1.0.
What is the impact of CVE-2024-45046?
The impact of CVE-2024-45046 allows an attacker to execute arbitrary JavaScript in the context of the affected web application.