CVE-2024-56408

5.4 MEDIUM

📋 TL;DR

This CVE describes a cross-site scripting (XSS) vulnerability in PhpSpreadsheet's sample engineering conversion script. Attackers can inject malicious scripts that execute in users' browsers when they access the vulnerable file. This affects all PhpSpreadsheet installations using vulnerable versions where the sample file is publicly accessible.

💻 Affected Systems

Products:
  • PHPOffice PhpSpreadsheet
Versions: All versions prior to 3.7.0, 2.3.5, 2.1.6, and 1.29.7
Operating Systems: All
Default Config Vulnerable: ✅ No
Notes: Only vulnerable if the sample file at /vendor/phpoffice/phpspreadsheet/samples/Engineering/Convert-Online.php is accessible via web server. Sample files are typically not deployed to production.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Attackers could steal session cookies, perform actions as authenticated users, deface websites, or redirect users to malicious sites if the vulnerable sample file is internet-facing.

🟠

Likely Case

Limited impact since this affects a sample file not typically used in production. Most likely scenario is defacement or limited data theft if the file is accidentally exposed.

🟢

If Mitigated

Minimal to no impact if the sample directory is properly restricted or removed from production environments.

🌐 Internet-Facing: MEDIUM
🏢 Internal Only: LOW

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

XSS exploitation is straightforward but requires the vulnerable file to be web-accessible. No authentication required.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 3.7.0, 2.3.5, 2.1.6, or 1.29.7 depending on your major version

Vendor Advisory: https://github.com/PHPOffice/PhpSpreadsheet/security/advisories/GHSA-x88g-h956-m5xg

Restart Required: No

Instructions:

1. Identify your PhpSpreadsheet major version (1.x, 2.x, or 3.x). 2. Update to the patched version using Composer: 'composer update phpoffice/phpspreadsheet'. 3. Verify the update completed successfully.

🔧 Temporary Workarounds

Remove sample files

all

Delete or restrict access to the vulnerable sample file

rm -rf vendor/phpoffice/phpspreadsheet/samples/

Restrict web access

all

Configure web server to block access to vendor directories

# Add to .htaccess for Apache: Deny from all
# Add to nginx config: location ~ /vendor/ { deny all; }

🧯 If You Can't Patch

  • Ensure the vendor directory is not web-accessible
  • Remove or restrict the samples/Engineering/ directory

🔍 How to Verify

Check if Vulnerable:

Check if vendor/phpoffice/phpspreadsheet/samples/Engineering/Convert-Online.php exists and is web-accessible

Check Version:

composer show phpoffice/phpspreadsheet | grep versions

Verify Fix Applied:

Verify PhpSpreadsheet version is 3.7.0+, 2.3.5+, 2.1.6+, or 1.29.7+ and check the file contains proper output escaping

📡 Detection & Monitoring

Log Indicators:

  • HTTP requests to /vendor/phpoffice/phpspreadsheet/samples/Engineering/Convert-Online.php with suspicious parameters

Network Indicators:

  • Unusual traffic patterns to sample files

SIEM Query:

web_access_logs WHERE uri CONTAINS 'vendor/phpoffice/phpspreadsheet/samples/Engineering/Convert-Online.php' AND (params CONTAINS '<script>' OR params CONTAINS 'javascript:')

🔗 References

📤 Share & Export