CVE-2025-22131: Phpoffice/phpspreadsheet Cross-Site Scripting Vulnerability

MODERATE
Advisory Identifier: GHSA-79xx-vf93-p7cx
CVSS 6.1
CWE-79
Published
Advisory Summary

CVE-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

CVE Identifier CVE-2025-22131
GHSA Identifier GHSA-79xx-vf93-p7cx
Severity MODERATE
CVSS v3.1 Base Score 6.1
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product Phpoffice/phpspreadsheet
Package Ecosystem Packagist
Published Date
Last Updated

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

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability None (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.

phpoffice/phpspreadsheet fixed: 3.8.0
Upgrade phpoffice/phpspreadsheet to 3.8.0
phpoffice/phpspreadsheet fixed: 1.29.8
Upgrade phpoffice/phpspreadsheet to 1.29.8
phpoffice/phpspreadsheet fixed: 2.1.7
Upgrade phpoffice/phpspreadsheet to 2.1.7
phpoffice/phpspreadsheet fixed: 2.3.6
Upgrade phpoffice/phpspreadsheet to 2.3.6
phpoffice/phpexcel fixed: Latest secure release
Upgrade phpoffice/phpexcel to Latest secure release
Verify Direct and Transitive Dependencies

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

### 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. ```php // 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 . '"><a href="#sheet' . $sheetId . '">' . $sheet->getTitle() . '</a></li>' . PHP_EOL; ++$sheetId; } $html .= '</ul>' . PHP_EOL; } ``` ### PoC 1. Create an XLSX file with multiple sheets : ![image](https://github.com/user-attachments/assets/e3fc027a-9525-4d7f-b107-cfa6e78d04e7) 2. Generate the HTML content ```php <?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(); ?> ``` 3. Enjoy ![image](https://github.com/user-attachments/assets/3e3c24f4-cb5d-451d-978f-9d33234f3bd1) ### 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. - ...

CVE-2025-22131 Affected Phpoffice/phpspreadsheet Versions

5 component(s)
Fixed Versions:
3.8.01.29.82.1.72.3.6
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?
CVE-2025-22131 is a security vulnerability in Phpoffice/phpspreadsheet involving Cross-Site Scripting (XSS) vulnerability in generateNavigation() function in PhpSpreadsheet under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which Phpoffice/phpspreadsheet versions are affected?
Affected versions include releases prior to 3.8.0, 1.29.8, 2.1.7, 2.3.6 across affected packages: phpoffice/phpspreadsheet, phpoffice/phpexcel.
What version fixes CVE-2025-22131?
Upgrading to 3.8.0, 1.29.8, 2.1.7, 2.3.6 (or the latest patched release for your respective branch) resolves the vulnerability.
Is phpoffice/phpspreadsheet affected?
Yes, phpoffice/phpspreadsheet is affected in releases prior to 3.8.0, 1.29.8, 2.1.7, 2.3.6. Upgrade your dependency to 3.8.0, 1.29.8, 2.1.7, 2.3.6 or later.
Is phpoffice/phpexcel affected?
Yes, phpoffice/phpexcel is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What is the CVSS score of CVE-2025-22131?
CVE-2025-22131 has a CVSS v3.1 base score of 6.1 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N.
What CWE is associated with CVE-2025-22131?
CVE-2025-22131 is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (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.).
How can I check Packagist dependencies for CVE-2025-22131?
Run the dependency tree command: 'inspect dependencies for phpoffice/phpspreadsheet'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "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![image](https://github.com/user-attachments/assets/e3fc027a-9525-4d7f-b107-cfa6e78d04e7)\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![image](https://github.com/user-attachments/assets/3e3c24f4-cb5d-451d-978f-9d33234f3bd1)\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"
  }
}