CVE-2024-56411: PhpSpreadsheet Cross-Site Scripting Vulnerability in HTML Header

phpoffice/phpspreadsheet Updated 02 Oct 2025

Summary

03/01/2025
Yes i
Moderate
5.4

CVE-2024-56411: Cross-Site Scripting (XSS) vulnerability of the hyperlink base in the HTML page header Product: Phpspreadsheet Version: version 3.6.0 CWE-ID: CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-si... Affects phpoffice/phpspreadsheet across 4 version ranges.

< 1.29.7 >= 2.0.0, < 2.1.6 >= 2.2.0, < 2.3.5 >= 3.0.0, < 3.7.0

Fixed in 4 releases; the minimum fixed version depends on the release line you run. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

Background

PhpSpreadsheet is a popular open-source library for reading and writing spreadsheet files in PHP. It allows developers to create, read, and manipulate Excel files in various formats, including XLSX and CSV. The library is widely used due to its ease of use and comprehensive feature set. However, it has been found to have a Cross-Site Scripting (XSS) vulnerability that arises from improper handling of hyperlink base in the HTML page header, potentially exposing users to malicious scripts.

Vulnerability Detail

The vulnerability originates from the way PhpSpreadsheet generates HTML representations of Excel files without properly sanitizing the hyperlink base. An attacker can exploit this flaw by embedding malicious JavaScript code in the properties of an Excel file. When a user opens a specially crafted Excel file, the malicious code can be executed in the user's browser, leading to unauthorized actions or data theft. The affected component is the 'generateHTMLHeader' method in the 'PhpOffice\PhpSpreadsheet\Writer\Html' class, which fails to sanitize user input adequately.

How To Fix

Fixed versions by release line

The minimum fixed version depends on the release line you run.

  • < 1.29.7 1.29.7
    composer require phpoffice/phpspreadsheet:1.29.7
  • >= 2.0.0, < 2.1.6 2.1.6
    composer require phpoffice/phpspreadsheet:2.1.6
  • >= 2.2.0, < 2.3.5 2.3.5
    composer require phpoffice/phpspreadsheet:2.3.5
  • >= 3.0.0, < 3.7.0 3.7.0
    composer require phpoffice/phpspreadsheet:3.7.0

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Workaround

As a temporary workaround, users can implement additional sanitization of special characters in the hyperlink base string before it is processed by PhpSpreadsheet. This can help mitigate the risk of XSS attacks until the library is updated.

Conclusion

The CVE-2024-56411 vulnerability in PhpSpreadsheet poses a significant risk due to its potential for Cross-Site Scripting attacks. Users are strongly advised to update to the latest versions of the library to mitigate this risk and ensure the safety of their applications.

See every vulnerability recorded for phpoffice/phpspreadsheet →

Share this vulnerability

FAQ

CVE-2024-56411 is a Cross-Site Scripting (XSS) vulnerability found in the PhpSpreadsheet library that allows attackers to execute arbitrary JavaScript code in the user's browser.

You can check if your application is affected by using Vulert, which monitors open-source vulnerabilities in your software. Visit Vulert Scanner to analyze your composer.lock file without needing to sign up.

The risks include unauthorized execution of JavaScript code, which can lead to data theft, session hijacking, or other malicious activities affecting users of the application.

To protect users, update PhpSpreadsheet to the latest patched version as soon as possible and consider implementing additional input sanitization as a temporary measure.

The vulnerability was discovered by Aleksey Solovev from Positive Technologies.

Related vulnerabilities

Recent vulnerabilities recorded for phpoffice/phpspreadsheet.

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

How To Fix

Fixed versions by release line

The minimum fixed version depends on the release line you run.

  • < 1.29.7 1.29.7
    composer require phpoffice/phpspreadsheet:1.29.7
  • >= 2.0.0, < 2.1.6 2.1.6
    composer require phpoffice/phpspreadsheet:2.1.6
  • >= 2.2.0, < 2.3.5 2.3.5
    composer require phpoffice/phpspreadsheet:2.3.5
  • >= 3.0.0, < 3.7.0 3.7.0
    composer require phpoffice/phpspreadsheet:3.7.0

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback