NewApp Monitoring is liveSign up free
AgentbeamBeta
Open-source package vulnerability · Composer (PHP)

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

mediumCVSS 4.0 4.8 · 3.1 5.4GHSA-wgmf-q9vr-vww6

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: 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.

Published Aug 29, 2024 · Updated Mar 6, 2025

Affected packages

phpoffice/phpspreadsheet

Ecosystem
Composer (PHP)
Affected
>= 2.0.0, < 2.1.0
Fixed in
2.1.0
Check
composer show phpoffice/phpspreadsheet

phpoffice/phpspreadsheet

Ecosystem
Composer (PHP)
Affected
< 1.29.1
Fixed in
1.29.1
Check
composer show phpoffice/phpspreadsheet

phpoffice/phpexcel

Ecosystem
Composer (PHP)
Affected
<= 1.8.2
Fixed in
No patched version yet
Check
composer show phpoffice/phpexcel

Advisory details

From the GitHub Advisory Database (CC BY 4.0).

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.

Credited to emilvirkki, marcinwealthon, neodc.

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology

More Composer (PHP) vulnerabilities

All Composer (PHP) entries