Problem/Motivation

PHP 8.0 no longer has phar vulnerability ref #3181240-5: Upgrade typo3/phar-stream-wrapper 3.1.6

The TYPO3/phar-stream-wrapper still used in 9.x core because it supports PHP 7.3

Proposed resolution

remove all usages and library dependency ASAP after core will require 8.0 as minimal version

Remaining tasks

- check all usage
- remove all usages of the library (code and composer dependencies)
- patch
- review/commit

User interface changes

no

API changes

tbd

Data model changes

no

Release notes snippet

Drupal 10 core no longer depends on the TYPO3/phar-stream-wrapper library, because this library is only needed for PHP 7.3 and earlier.

Issue fork drupal-3210486

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

andypost created an issue. See original summary.

andypost’s picture

could need change record

andypost’s picture

Usage is

- \Drupal\Core\Security\PharExtensionInterceptor needs class deprecation
- \Drupal\Core\DrupalKernel::boot() - just removal

gábor hojtsy’s picture

This cannot happen in Drupal 9 as Drupal 9 will not require PHP 8. However Drupal 10 will require PHP 8 according to current plans, so moving there.

gábor hojtsy’s picture

Title: Remove typo3/phar-stream-wrapper as core require PHP 8 » Remove typo3/phar-stream-wrapper once core requires PHP 8
andypost’s picture

Issue tags: +Deprecation Removal

Spokje made their first commit to this issue’s fork.

spokje’s picture

Status: Active » Needs review

Although the tests (will) return green, this doesn't feel right to me.

\Drupal\Core\Security\PharExtensionInterceptor is not used anywhere any more (was only used in \Drupal\Core\DrupalKernel::boot() and not in any test classes).

- Adding a deprecation that's never triggered doesn't seem right.
- Leaving a file (core/lib/Drupal/Core/Security/PharExtensionInterceptor.php) that has undefined classes (YPO3\PharStreamWrapper\* can't be loaded since typo3/phar-stream-wrapper is no longer pulled in) doesn't seem right.

Personally I would rather do #3181275: Do not register Phar stream wrapper on PHP 8 because it is not vulnerable to unserialize bugs first and deprecate \Drupal\Core\Security\PharExtensionInterceptor there in 9.4.0 and remove in 10.0.0.

Putting this on Needs Review anyway to get more eyes/minds/random body-parts on this.

longwave’s picture

Do we need a deprecation at all? Can we consider PharExtensionInterceptor as internal as it's a very specialist class that was only used by our kernel?

spokje’s picture

@longwave: Like that idea, but since it wasn't tagged as @internal, there _could_ be Contrib/Custom modules out there using it (although I think the chances are pretty slim on that)

Doing a search on PharExtensionInterceptor in Contrib reveals no usage: http://grep.xnddx.ru/search?text=PharExtensionInterceptor&filename=

Since this is a case that's not really (fully) covered by the Drupal deprecation policy, maybe we can get away with just removing it?

andypost’s picture

++ to mark internal in separate issue with CR

spokje’s picture

++ to mark internal in separate issue with CR

Thus spoketh @andypost in #12

I think that would be a very nice solution!
Opened #3252406: Mark class \Drupal\Core\Security\PharExtensionInterceptor as internal to mark \Drupal\Core\Security\PharExtensionInterceptor in 9.4.x, so we can remove it without deprecation here after that issue lands.

spokje’s picture

Title: Remove typo3/phar-stream-wrapper once core requires PHP 8 » [PP-1] Remove typo3/phar-stream-wrapper once core requires PHP 8
Status: Needs review » Postponed
alexpott’s picture

Title: [PP-1] Remove typo3/phar-stream-wrapper once core requires PHP 8 » Remove typo3/phar-stream-wrapper and associated code
Status: Postponed » Active
longwave’s picture

Status: Active » Needs review
StatusFileSize
new10.66 KB

longwave’s picture

StatusFileSize
new10.16 KB

Deleted a bit too much.

alexpott’s picture

Status: Needs review » Needs work
+++ b/core/tests/Drupal/KernelTests/Core/File/PharWrapperTest.php
@@ -23,18 +23,7 @@ public function testPharFile() {
+    $this->assertFalse(file_exists("phar://$base/image-2.jpg/index.php"));

Looking at this now I realise that this should be $this->assertFileDoesNotExist()

No harm in tweaking that here.

alexpott’s picture

Actually ignore #19. I think we can remove \Drupal\KernelTests\Core\File\PharWrapperTest and core/tests/fixtures/files/phar-1.phar - this fixture is now only testing the default stream wrapper that comes with PHP and I don't think we should be testing that.

The whole assert on $this->assertFileDoesNotExist("phar://$base/image-2.jpg/index.php"); is pretty bogus for PHP 8. We're not doing user-land phar file stream wrappers and we have no code that's doing anything in this space - ie we're removing \Drupal\Core\Security\PharExtensionInterceptor and the Typo3 code.

longwave’s picture

In that case #16 was right all along.

@alexpott what do think about removing StreamWrapperTest::testPharStreamWrapperRegistration() as well? I think that only exists because of the Typo3 interceptor.

longwave’s picture

Status: Needs work » Needs review
StatusFileSize
new12.49 KB

#16 with the removal of StreamWrapperTest::testPharStreamWrapperRegistration() as well. One of the comments mentions PharStreamWrapperManager, that is now gone.

alexpott’s picture

Can also remove core/tests/fixtures/files/phar-1.phar

spokje’s picture

StatusFileSize
new19.77 KB
new7.17 KB
andypost’s picture

Status: Needs review » Reviewed & tested by the community

Looks ready

  • catch committed 9f5c2e9 on 10.0.x
    Issue #3210486 by Spokje, longwave, andypost, alexpott: Remove typo3/...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed 9f5c2e9 and pushed to 10.0.x. Thanks!

xjm’s picture

Issue tags: +10.0.0 release notes

Oh nice, I hadn't thought about the fact that we don't need it anymore. Yay!

Remember to tag dependency changes for the release notes.

xjm’s picture

Issue summary: View changes

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.