CVE-2024-45046: Phpoffice/phpspreadsheet Cross-Site Scripting Vulnerability
MODERATECVE-2024-45046 is a MODERATE (CVSS 5.4) cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Phpoffice/phpspreadsheet libraries in the Packagist ecosystem. The issue involves phpspreadsheet html writer is vulnerable to cross-site scripting via style information. Remediation is available by upgrading affected packages to version 2.1.0, 1.29.1.
CVE-2024-45046 at a Glance
Security Impact
CVSS: 5.4
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N).
How to Fix CVE-2024-45046
To remediate this vulnerability, upgrade all affected Phpoffice/phpspreadsheet dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade phpoffice/phpspreadsheet to 2.1.0
Upgrade phpoffice/phpspreadsheet to 1.29.1
Upgrade phpoffice/phpexcel to Latest secure release
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for phpoffice/phpspreadsheet
How to Check if You Are Affected
To determine whether your application is affected by CVE-2024-45046, inspect your project dependencies for Phpoffice/phpspreadsheet:
inspect dependencies for phpoffice/phpspreadsheet
Analyze the terminal output to locate any version of Phpoffice/phpspreadsheet in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.1.0), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In Phpoffice/phpspreadsheet, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2024-45046 Affected Phpoffice/phpspreadsheet Versions
3 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
phpoffice/phpspreadsheet
|
Packagist |
≥ 2.0.0
< 2.1.0
|
2.1.0
|
|
phpoffice/phpspreadsheet
|
Packagist |
< 1.29.1
|
1.29.1
|
|
phpoffice/phpexcel
|
Packagist |
≤ 1.8.2
|
|
References
Frequently Asked Questions
What is CVE-2024-45046?
Which Phpoffice/phpspreadsheet versions are affected?
What version fixes CVE-2024-45046?
Is phpoffice/phpspreadsheet affected?
Is phpoffice/phpexcel affected?
What is the CVSS score of CVE-2024-45046?
What CWE is associated with CVE-2024-45046?
How can I check Packagist dependencies for CVE-2024-45046?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-wgmf-q9vr-vww6",
"modified" : "2025-03-06T18:09:33Z",
"published" : "2024-08-29T17:56:56Z",
"aliases" : [ "CVE-2024-45046" ],
"summary" : "PhpSpreadsheet HTML writer is vulnerable to Cross-Site Scripting via style information",
"details" : "### Summary\n\n`\\PhpOffice\\PhpSpreadsheet\\Writer\\Html` doesn't sanitize spreadsheet styling information such as font names, allowing an attacker to inject arbitrary JavaScript on the page.\n\n### PoC\n\nExample target script:\n\n```\n<?php\n\nrequire 'vendor/autoload.php';\n\n$reader = \\PhpOffice\\PhpSpreadsheet\\IOFactory::createReader(\"Xlsx\");\n$spreadsheet = $reader->load(__DIR__ . '/book.xlsx');\n\n$writer = new \\PhpOffice\\PhpSpreadsheet\\Writer\\Html($spreadsheet);\nprint($writer->generateHTMLAll());\n```\n\nSave this file in the same directory:\n[book.xlsx](https://github.com/PHPOffice/PhpSpreadsheet/files/15212797/book.xlsx)\n\nOpen index.php in a web browser. An alert should be displayed.\n\n### Impact\n\nFull takeover of the session of users viewing spreadsheet files as HTML.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N"
}, {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:A/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Packagist",
"name" : "phpoffice/phpspreadsheet"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2.0.0"
}, {
"fixed" : "2.1.0"
} ]
} ]
}, {
"package" : {
"ecosystem" : "Packagist",
"name" : "phpoffice/phpspreadsheet"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.29.1"
} ]
} ]
}, {
"package" : {
"ecosystem" : "Packagist",
"name" : "phpoffice/phpexcel"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"last_affected" : "1.8.2"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/PHPOffice/PhpSpreadsheet/security/advisories/GHSA-wgmf-q9vr-vww6"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-45046"
}, {
"type" : "WEB",
"url" : "https://github.com/PHPOffice/PhpSpreadsheet/pull/3957"
}, {
"type" : "WEB",
"url" : "https://github.com/PHPOffice/PhpSpreadsheet/commit/f7cf378faed2e11cf4825bf8bafea4922ae44667"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/PHPOffice/PhpSpreadsheet"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-79" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2024-08-29T17:56:56Z",
"nvd_published_at" : "2024-08-28T21:15:06Z"
}
}