Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insecure Random number generation #1020

Open
vjaykoogu opened this issue Jan 16, 2024 · 1 comment
Open

Insecure Random number generation #1020

vjaykoogu opened this issue Jan 16, 2024 · 1 comment
Labels
security session Session Management

Comments

@vjaykoogu
Copy link

Description

We found vlunerability in PEN test results.

Environment

  • ADOdb version: 5.22.7
  • Driver or Module: ADOdb
  • PHP version: 8.1
  • Platform: Linux

Error found in below files and Method to Change.

image

  • In above Screenshot we see filename and methos to change.

Fix

Using Below solution:
To generate secure random numbers in PHP, I'll be using random_int() function or the random_bytes() function, which are specifically designed for cryptographic purposes and provide a higher level of randomness.

To generate a random number within a specified range:
$randomNumber = random_int($min, $max);

To generate random bytes for cryptographic purposes.
$randomBytes = random_bytes($length);

@vjaykoogu vjaykoogu added the triage New issues not yet reviewed by ADOdb developers label Jan 16, 2024
@dregad
Copy link
Member

dregad commented Jan 16, 2024

Thanks for your report. Please note

  • adodb-time.inc.php was deprecated in 5.22.6 and removed in 5.23.0, see Remove obsolete Date/Time library #970
  • not all usage of rand() actually requires a CSPRNG... your list contains mostly false positives

At first glance, only usages around ADOdb sessions (crypt.inc.php, adodb-session*.php are potentially problematic.

This code is very old and shows its age... An in-depth refactoring would be needed, replacing rand() by random_int() would only scratch the surface and be kind of pointless, considering we have code performing md5 / sha1 "encryption", or relying on mcrypt (removed in PHP 7.2).

@dregad dregad changed the title PHP-Insecure Random (PEN test vlunerability) Insecure Random number generation Jan 16, 2024
@dregad dregad added security session Session Management and removed triage New issues not yet reviewed by ADOdb developers labels Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
security session Session Management
Projects
None yet
Development

No branches or pull requests

2 participants