Medium

PhpSpreadsheet HTML writer is vulnerable to Cross-Site Scripting via JavaScript hyperlinks

  • Disclosed: 07.10.2024
  • Updated: 11.10.2026 10:22

Summary

\PhpOffice\PhpSpreadsheet\Writer\Html does not sanitize "javascript:" URLs from hyperlink href attributes, resulting in a Cross-Site Scripting vulnerability.

PoC

Example target script:

php
<?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 and click on both links. The first demonstrates the vulnerability in a regular hyperlink and the second in a HYPERLINK() formula.

Affected software

Click a technology to see all vulnerabilities affecting it.

PlatformPackageVulnerable versionsFixed in
Composer package phpoffice/phpexcel <= 1.8.2 no fix
Composer package phpoffice/phpspreadsheet >= 2.2.0, < 2.3.0, < 1.29.2, >= 2.0.0, < 2.1.1 2.3.0, 1.29.2, 2.1.1

References

CVSS score 5.4/10
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N
Weakness (CWE)
CWE-79
Platform
Composer
Package
phpoffice/phpexcel, phpoffice/phpspreadsheet
Disclosed
07.10.2024
Updated
11.10.2026 10:22

Sources and licenses

OSV / GitHub Advisory Database - GHSA-r8w8-74ww-j4wh - CC BY 4.0

Vulnerability history: phpoffice/phpexcel

All published vulnerabilities of this package (Composer package), newest first. Shows whether this is a one-off slip or a package that needs watching.

All (23) in the archive
Total entries
23
First → latest
11.2019 02.2025
Without a fix
20
Exploited in attacks
0

Severity breakdown

  • High 12
  • Medium 10
  • Low 1

Disclosures per year

  1. 2019: 2
  2. 2020: 0
  3. 2021: 1
  4. 2022: 1
  5. 2023: 0
  6. 2024: 10
  7. 2025: 9
  8. 2026: 0
Severity:
  1. High · 7.5 CVE-2024-48917 <= 1.8.2 no fix
  2. High · 7.5 CVE-2024-47873 <= 1.8.2 no fix
  3. High CVE-2015-3542 < 1.8.1 1.8.1
  4. PhpSpreadsheet HTML writer is vulnerable to Cross-Site Scripting via JavaScript hyperlinks this entry
    Medium · 5.4 CVE-2024-45292 <= 1.8.2 no fix
  5. High · 7.5 CVE-2024-45293 <= 1.8.2 no fix
  6. High · 8.8 CVE-2024-45048 <= 1.8.2 no fix
  7. High · 8.8 CVE-2018-19277 < 1.8.2 1.8.2

Know which vulnerabilities affect your application

With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.

Connect your application
DockRay newsletter

Application security in your inbox

Important vulnerabilities, actionable guidance and practical advice for your applications. Choose your technologies and follow what matters to your project.

  • A daily digest of new vulnerabilities, critical ones included.
  • Notifications about important updates.
  • Practical advice on application security and monitoring.

Leave empty to receive updates for every technology.

Free to subscribe. Unsubscribe with one click in any email.