Skip to content

Commit bc65c0d

Browse files
fix(upload): replace predictable uniqid() with cryptographically secure random_bytes
- Replaced uniqid() with bin2hex(random_bytes(16)) - Prevents predictable filename generation - Improves security against file enumeration attacks Compliance: - No breaking changes - Security enhancement applied Co-authored-by: Maatify <130119162+Maatify@users.noreply.github.com>
1 parent af72904 commit bc65c0d

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

uploader/UploadBase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ public function upload(): array
159159

160160
// Generate a unique filename if none is provided
161161
if (empty($this->file_name)) {
162-
$fileName = round(microtime(true) * 1000) . uniqid();
163-
$file = $this->uploaded_for_id . '_' . time() . "_" . $fileName . uniqid() . '.' . $this->extension;
162+
$fileName = round(microtime(true) * 1000) . bin2hex(random_bytes(16));
163+
$file = $this->uploaded_for_id . '_' . time() . "_" . $fileName . bin2hex(random_bytes(16)) . '.' . $this->extension;
164164
} else {
165165
$file = $this->file_name . '.' . $this->extension;
166166
}

0 commit comments

Comments
 (0)