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

CVE-2025-22131: Cross-Site Scripting (XSS) vulnerability in generateNavigation() function in PhpSpreadsheet

mediumCVSS 4.0 5.1 · 3.1 6.1GHSA-79xx-vf93-p7cx

Summary The 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. Details When 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.

Published Jan 21, 2025 · Updated Mar 6, 2025

Affected packages

phpoffice/phpspreadsheet

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

phpoffice/phpspreadsheet

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

phpoffice/phpspreadsheet

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

phpoffice/phpspreadsheet

Ecosystem
Composer (PHP)
Affected
>= 2.2.0, < 2.3.6
Fixed in
2.3.6
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

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

Details

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

        // Construct HTML
        $html = '';

        // Only if there are more than 1 sheets
        if (count($sheets) > 1) {
            // Loop all sheets
            $sheetId = 0;

            $html .= '<ul class="navigation">' . PHP_EOL;

            foreach ($sheets as $sheet) {
                $html .= '  <li class="sheet' . $sheetId . '">' . $sheet->getTitle() . '</li>' . PHP_EOL;
                ++$sheetId;
            }

            $html .= '</ul>' . PHP_EOL;
        }

PoC

  1. Create an XLSX file with multiple sheets :

image

  1. Generate the HTML content
<?php
	require __DIR__ . '/vendor/autoload.php';

	$inputFileName = 'payload.xlsx';
	$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($inputFileName);
	$writer = new \PhpOffice\PhpSpreadsheet\Writer\Html($spreadsheet);
	$writer->writeAllSheets();
	echo $writer->generateHTMLAll();
?>
  1. Enjoy

image

Impact

XSS can cause a variety of problems for the end user that range in severity from an annoyance to complete account compromise. Example of impacts :

  • 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).
  • Redirecting the user to some other page or site (like phishing websites)
  • Modifying the content of the current page (add a fake login page that sends credentials to the attacker).
  • Automatically download malicious files.
  • Requests access to the victim geolocation / camera.
  • ...

Credited to TRIKKSS.

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