Review 14.3 Merged

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

Garvin Hicking CR +2 V +2 Hard +261 −4 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 13

Review log 46

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

    Cherry Picked from branch main.
  2. core-ci voted on patch set 1 V -1 07/01/26, 14:53 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/104155

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

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

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

  6. Garvin Hicking merged patch set 3 07/01/26, 16:44