Random numbers come from rand, whose quality and range are poor and whose state is shared

tx0/cpp:c-random-generatorstrictnotesecurity/cryptodepth fastsecurity, cwe-338

What it finds

rand() has an implementation-defined algorithm, often a weak linear congruential generator with as few as 15 bits, and one hidden global state. The engines and distributions of <random> are specified and can be seeded per use; for secrets, an operating system source is needed.

From the rule's source, c_random_generator.rs.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/cpp:c-random-generator" = "note"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/cpp:c-random-generator] reason="..."

tx0 explain tx0/cpp:c-random-generator shows the same in the terminal. Found a false positive? Report it.