Review main Abandoned

93972[TASK] Replace predictable uniqid() calls with StringUtility::getUniqueId(

TYPO3com CR 0 V 0 Easy +6 −4 updated 05/05/26, 05:28

Commit message

This PR addresses an insecure design pattern by replacing occurrences of
the unsafe `uniqid()` function within the Styleguide ViewHelpers
(`ExampleViewHelper`, `CodeViewHelper`, and `ColorSchemeViewHelper`).

The `uniqid()` function produces predictable values based on the current
system time in microseconds, which violates secure-by-design principles
when generating unique identifiers. This patch eliminates this unsafe
library call by migrating to TYPO3's own `StringUtility::getUniqueId()`,
which securely utilizes `random_bytes()` under the hood to generate
cryptographically safe randomness.

How the patch works:
The patch systematically replaces all usages of `uniqid()` in the
Styleguide extension's ViewHelpers with `StringUtility::getUniqueId()`.

- In `ExampleViewHelper.php` and `CodeViewHelper.php`, `uniqid('code')`
was updated to `StringUtility::getUniqueId('code')`, and the `use
TYPO3\CMS\Core\Utility\StringUtility;` import statement was added to the
file header.
- In `ColorSchemeViewHelper.php`, `uniqid($defaultScheme)` was updated to
`StringUtility::getUniqueId($defaultScheme)`. The file already had the
`StringUtility` import, so no header changes were required.

Security Impact:
The primary security impact is proactive hardening. By removing
`uniqid()`, we eliminate an error-prone design pattern.
`StringUtility::getUniqueId()` delegates to `random_bytes(13)`, which
provides high-entropy, cryptographically secure randomness, ensuring that
the generated identifiers cannot be easily guessed or predicted.

Review

  • Code review CR 0
  • Verified V 0

Issues 1

Files 3

Review log 12

  1. TYPO3com uploaded patch set 1 05/05/26, 05:24

  2. Oliver Hader abandoned the change 05/05/26, 05:28