Skip to content

Insecure random number generation in getkey() #464

@rcbarnett-zz

Description

@rcbarnett-zz

MODSEC-316: I think there are a couple of problems with the getkey() implementation.

  1. If the purpose of the key is to use it for crypto operations (I have not reviewed any other code, so I don't know.), then the standard random number generator is not sufficient. You'll want to use a proper PRNG.
  2. Even that aside, in the current implementation, time is used to seed the RNG, but its resolution of the clock is in seconds. Which means it is easily predictable.
  3. Re-seeding in the loop does not contribute to the randomness, and may actually be affecting it negatively.
  4. From a glance, the loop does not seem correct. There might be an off-by-one issue there.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions