Review 13.4 Merged

94649[TASK] Implement and apply custom PHPStan rule to harden `unserialize`

Garvin Hicking CR +2 V +2 Hard +261 −17 updated 07/01/26, 16:44

Commit message

This patch integrates a custom PHPStan rule to detect unsecure or
invalid calls to the `unserialize` function. The rule was copied over
from [1] and may get removed again once it is merged into PHPStan core.

As a consequence, remaining potentially insecure `unserialize` calls
are covered by `@phpstan-ignore` annotations. This affects the following
code parts:

* `AuthenticatedMessageDeserializer`: Doing `unserialize` with
  `['allowed_classes' => true]` at this point is intended, as the
  relevant integrity check already happens via HMAC validation.
* `ActionController`: Same here (HMAC validation)
* `FormRuntime`: Same here (HMAC validation)
* Tests: Doing insecure `unserialize` in tests is currently ignored,
  because the effect of having potential security leaks is extreme low.

To allow PHPStan to properly detect the types used for `unserialize` in
`PackageCacheEntry`, this class now receives higher type coverage.

[1]: https://github.com/phpstan/phpstan-src/pull/4754

Review

  • Code review CR +2 Done
    • Garvin Hicking +2
  • Verified V +2 Done
    • Garvin Hicking +2
    • core-ci +1 CI

Issues 1

Files 14

Review log 69

  1. Garvin Hicking commented on patch set 1 07/01/26, 14:40

    Cherry Picked from branch main. The following files contain Git conflicts: * typo3/sysext/core/Classes/Package/Cache/PackageCacheEntry.php * typo3/sysext/extbase/Tests/Functional/Persistence/LazyLoadingProxyTest.php * typo3/sysext/extbase/Tests/Functional/Persistence/LazyObjectStorageTest.php
  2. Garvin Hicking commented on patch set 2 07/01/26, 14:44

    Published edit on patch set 1.
  3. core-ci voted on patch set 1 V -1 07/01/26, 14:46 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/104156

  4. core-ci voted on patch set 2 V -1 07/01/26, 14:51 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/104157

  5. Elias Häußler uploaded patch set 3 V -1 07/01/26, 15:16

  6. core-ci voted on patch set 3 V +1 07/01/26, 15:23 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/104193

  7. Garvin Hicking marked it ready for review 07/01/26, 16:42

  8. Garvin Hicking voted on patch set 3 CR +2 V +2 07/01/26, 16:44

  9. Garvin Hicking merged patch set 4 07/01/26, 16:44