Review main Merged

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

Elias Häußler CR +2 V +2 Hard +260 −3 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
    • Oliver Hader +1
    • Simon Schaufelberger +1
  • Verified V +2 Done
    • Garvin Hicking +2
    • Oliver Klee +1
    • Oliver Hader +1
    • core-ci +1 CI

Issues 1

Files 12

Review log 911

  1. Elias Häußler uploaded patch set 1 06/29/26, 13:13

  2. core-ci voted on patch set 1 V -1 06/29/26, 13:20 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/104032

  3. Simon Schaufelberger commented on patch set 1 06/29/26, 13:21

    PackageCacheEntry.php:51

    this is of type array but annotated as plain object. is that correct?
  4. Elias Häußler commented on patch set 1 06/29/26, 13:24

  5. core-ci voted on patch set 1 V +1 06/29/26, 13:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/104032

  6. Simon Schaufelberger commented on patch set 1 CR +1 06/29/26, 13:39

    PackageCacheEntry.php:51 Reply

    Acknowledged
  7. Garvin Hicking voted on patch set 1 CR +1 V +1 06/29/26, 16:34

  8. Oliver Hader commented on patch set 1 CR +1 V +1 07/01/26, 10:07

    Nice ❤️
  9. Oliver Klee voted on patch set 1 V +1 07/01/26, 11:53

  10. Garvin Hicking voted on patch set 1 CR +2 V +2 07/01/26, 16:43

  11. Garvin Hicking merged patch set 2 07/01/26, 16:44