CVE-2024-45046: PhpSpreadsheet HTML writer is vulnerable to Cross-Site Scripting via style information

Published Aug 28, 2024
·
Updated

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

5 affected componentsFixes available
PHPOffice phpspreadsheet<1.29.1
PHPOffice phpspreadsheet>=2.0.0<2.1.0
composer/phpoffice/phpexcel<=1.8.2
composer/phpoffice/phpspreadsheet<1.29.1
1.29.1
composer/phpoffice/phpspreadsheet>=2.0.0<2.1.0
2.1.0

Event History

Aug 28, 2024
CVE Published
via MITRE·08:41 PM
Data Sourced
via MITRE·08:41 PM
DescriptionSeverityWeakness
Aug 29, 2024
Advisory Published
via GitHub·05:56 PM
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2024-45046?

CVE-2024-45046 has a high severity rating due to the potential for arbitrary JavaScript injection.

2

How do I fix CVE-2024-45046?

To fix CVE-2024-45046, upgrade to PhpSpreadsheet version 1.29.1 or 2.1.0.

3

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.

4

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.

5

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.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203