Deterministic random output from constant seed
Seeding routine uses a constant seed making the output deterministic
Description
This defect occurs when you use standard random number generator functions that have deterministic output given a constant seed.
The checker detects this issue with the following random number generator functions:
C Standard Library functions such as
srand
,srandom
andinitstate
OpenSSL functions such as
RAND_seed
andRAND_add
C++ Standard Library functions such as
std::linear_congruential_engine<>::seed()
andstd::mersenne_twister_engine<>::seed()
(and also the constructors of these class templates)
Risk
With constant seeds, random number generator functions produce the same output every time your program is run. A hacker can disrupt your program if they know how your program behaves.
Fix
Use a different random standard function or use a nonconstant seed.
Some standard random routines are inherently cryptographically weak, and should not be used for security purposes.
Examples
Result Information
Group: Security |
Language: C | C++ |
Default: Off |
Command-Line Syntax:
RAND_SEED_CONSTANT |
Impact: Medium |
Version History
Introduced in R2015b
See Also
Predictable random output from predictable seed
| Unsafe standard encryption function
| Vulnerable pseudo-random number generator
| Find defects (-checkers)
Topics
- Interpret Bug Finder Results in Polyspace Desktop User Interface
- Interpret Bug Finder Results in Polyspace Access Web Interface (Polyspace Access)
- Address Results in Polyspace User Interface Through Bug Fixes or Justifications
- Address Results in Polyspace Access Through Bug Fixes or Justifications (Polyspace Access)