Review main Abandoned

93946[TASK] Replace unsafe rand() with random_int() in UserSessionManager

TYPO3com CR -1 V 0 Easy +1 −1 updated 08/06/26, 15:59

Commit message

This patch proactively improves the security posture of the session
management system by eliminating an error-prone design pattern related to
randomness.

In `UserSessionManager.php`, the garbage collection probability was
calculated using `rand(0, 99)`. The standard `rand()` function is a weak
pseudo-random number generator and is considered an unsafe library call in
contexts like session management.

This patch replaces it with `random_int(0, 99)`, which generates
cryptographically secure, unbiased random integers. While the patch is a
simple one-liner, it systematically removes a native PHP function known to
be insecure and replaces it with the modern, secure standard.

Review

  • Code review CR -1
    • Mathias Brodala -1
  • Verified V 0
    • core-ci +1 CI

Issues 1

Files 1

Review log 46

  1. TYPO3com uploaded patch set 1 05/04/26, 15:56

  2. core-ci voted on patch set 1 V +1 05/04/26, 16:07 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/101478

  3. Christian Kuhn commented on patch set 1 CR -1 05/04/26, 16:19

    Unresolved

    imho NACK: GC scheduling dice roll is an internal thing that never leaves the server. it is not involved in session id creation or anything similar. also, rand() is used here since random_int() may throw if no entropy is available. in case a linter complains, we could switch to mt_rand(), which may make the intention more clear.
  4. Mathias Brodala commented on patch set 1 CR -1 05/06/26, 05:11

    Unresolved

    AFAIS this is an AI generated suggestion, the wording sounds quite artificial and unnecessarily verbose. Also the author https://github.com/jmestwa-coder only started coding on Github in March and has already created PRs in many completely unrelated repositories. And I agree with lolli, the broader context (session management) may be security-relevant but the actual context (garbage collection) is not, so an "unsecure" randomness is fine.
  5. Christian Kuhn wrote 06/18/26, 23:11

    Removed reviewer Christian Kuhn with the following votes: * Code-Review-1 by Christian Kuhn
  6. Garvin Hicking abandoned the change 08/06/26, 15:59