← PHP / Laravel · 目次

PHP-081 / 上級

一時ファイル作成時の uniqid() のみの使用

A02:2021 Cryptographic Failures · CWE-340 Generation of Predictable Numbers or Identifiers

なぜ問題になるのか?

uniqid() は時間ベースなので推測可能です。

修正方法

php
$downloadKey = bin2hex(random_bytes(16));

参考資料