CVE-2025-22131: Phpoffice/phpspreadsheet Cross-Site Scripting Vulnerability
MODERATECVE-2025-22131 is a MODERATE (CVSS 6.1) 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 cross-site scripting (xss) vulnerability in generatenavigation() function in phpspreadsheet. Remediation is available by upgrading affected packages to version 3.8.0, 1.29.8, 2.1.7, 2.3.6.
CVE-2025-22131 at a Glance
Security Impact
CVSS: 6.1
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N).
How to Fix CVE-2025-22131
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 3.8.0
Upgrade phpoffice/phpspreadsheet to 1.29.8
Upgrade phpoffice/phpspreadsheet to 2.1.7
Upgrade phpoffice/phpspreadsheet to 2.3.6
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-2025-22131, 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 3.8.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-2025-22131 Affected Phpoffice/phpspreadsheet Versions
5 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
phpoffice/phpspreadsheet
|
Packagist |
≥ 3.0.0
< 3.8.0
|
3.8.0
|
|
phpoffice/phpspreadsheet
|
Packagist |
< 1.29.8
|
1.29.8
|
|
phpoffice/phpspreadsheet
|
Packagist |
≥ 2.0.0
< 2.1.7
|
2.1.7
|
|
phpoffice/phpspreadsheet
|
Packagist |
≥ 2.2.0
< 2.3.6
|
2.3.6
|
|
phpoffice/phpexcel
|
Packagist |
≤ 1.8.2
|
|
References
Frequently Asked Questions
What is CVE-2025-22131?
Which Phpoffice/phpspreadsheet versions are affected?
What version fixes CVE-2025-22131?
Is phpoffice/phpspreadsheet affected?
Is phpoffice/phpexcel affected?
What is the CVSS score of CVE-2025-22131?
What CWE is associated with CVE-2025-22131?
How can I check Packagist dependencies for CVE-2025-22131?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-79xx-vf93-p7cx",
"modified" : "2025-03-06T18:16:08Z",
"published" : "2025-01-21T21:09:13Z",
"aliases" : [ "CVE-2025-22131" ],
"summary" : "Cross-Site Scripting (XSS) vulnerability in generateNavigation() function in PhpSpreadsheet",
"details" : "### Summary\nThe researcher discovered zero-day vulnerability Cross-Site Scripting (XSS) vulnerability in the code which translates the XLSX file into a HTML representation and displays it in the response.\n\n### Details\nWhen generating the HTML from an xlsx file containing multiple sheets, a navigation menu is created. This menu includes the sheet names, which are not sanitized. As a result, an attacker can exploit this vulnerability to execute JavaScript code.\n\n```php\n // Construct HTML\n $html = '';\n\n // Only if there are more than 1 sheets\n if (count($sheets) > 1) {\n // Loop all sheets\n $sheetId = 0;\n\n $html .= '<ul class=\"navigation\">' . PHP_EOL;\n\n foreach ($sheets as $sheet) {\n $html .= ' <li class=\"sheet' . $sheetId . '\"><a href=\"#sheet' . $sheetId . '\">' . $sheet->getTitle() . '</a></li>' . PHP_EOL;\n ++$sheetId;\n }\n\n $html .= '</ul>' . PHP_EOL;\n }\n```\n\n### PoC\n1. Create an XLSX file with multiple sheets : \n\n\n2. Generate the HTML content \n```php\n<?php\n\trequire __DIR__ . '/vendor/autoload.php';\n\n\t$inputFileName = 'payload.xlsx';\n\t$spreadsheet = \\PhpOffice\\PhpSpreadsheet\\IOFactory::load($inputFileName);\n\t$writer = new \\PhpOffice\\PhpSpreadsheet\\Writer\\Html($spreadsheet);\n\t$writer->writeAllSheets();\n\techo $writer->generateHTMLAll();\n?>\n```\n3. Enjoy\n\n\n\n### Impact\n\nXSS can cause a variety of problems for the end user that range in severity from an annoyance to complete account compromise.\nExample of impacts :\n\n- Disclosure of the user’s session cookie, allowing an attacker to hijack the user’s session and take over the account (Only if HttpOnly cookie's flag is set to false).\n- Redirecting the user to some other page or site (like phishing websites)\n- Modifying the content of the current page (add a fake login page that sends credentials to the attacker).\n- Automatically download malicious files.\n- Requests access to the victim geolocation / camera.\n- ...",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N"
}, {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:A/VC:L/VI:L/VA:N/SC:L/SI:L/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Packagist",
"name" : "phpoffice/phpspreadsheet"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "3.0.0"
}, {
"fixed" : "3.8.0"
} ]
} ]
}, {
"package" : {
"ecosystem" : "Packagist",
"name" : "phpoffice/phpspreadsheet"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.29.8"
} ]
} ]
}, {
"package" : {
"ecosystem" : "Packagist",
"name" : "phpoffice/phpspreadsheet"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2.0.0"
}, {
"fixed" : "2.1.7"
} ]
} ]
}, {
"package" : {
"ecosystem" : "Packagist",
"name" : "phpoffice/phpspreadsheet"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2.2.0"
}, {
"fixed" : "2.3.6"
} ]
} ]
}, {
"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-79xx-vf93-p7cx"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-22131"
}, {
"type" : "WEB",
"url" : "https://github.com/PHPOffice/PhpSpreadsheet/commit/4088381ccfaf241d7d42c333de0dc8c98e338743"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/PHPOffice/PhpSpreadsheet"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-79" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2025-01-21T21:09:13Z",
"nvd_published_at" : "2025-01-20T16:15:27Z"
}
}