#109757Replace predictable uniqid() calls with StringUtility::getUniqueId() in Styleguide ViewHelpers
Description
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.
This issue was automatically created from https://github.com/TYPO3/typo3/pull/635
Reviews 1
History 23
-
Gerrit Code Review pushed patch set 1 for main to change 93947 status
NewUnder Review <span data-processor="relativetime" data-value="2026-05-04T16:06:43+00:00" > 05/04/26, 16:06 </span> -
Oliver Hader changed Duplicated by #109766 <span data-processor="relativetime" data-value="2026-05-05T05:27:24+00:00" > 05/05/26, 05:27 </span>
-
Georg Ringer commented and changed status
Under ReviewClosed <span data-processor="relativetime" data-value="2026-10-06T15:52:04+00:00" > 10/06/26, 15:52 </span>
no interest in that issue, closing