A value that looks like a secret is made with rand, whose output can be predicted

tx0/cpp:predictable-random-secretrecommendedwarningsecurity/cryptodepth fastsecurity, cwe-338

What it finds

session->token = rand();: rand and random are generators whose whole state can be worked out from a few outputs, and are often seeded with the time. Keys, tokens, salts and nonces need a cryptographic source such as getrandom or arc4random.

The result must be stored, directly or in an expression, in a variable or field whose name has a part such as key, token, secret, nonce, salt or password.

From the rule's source, predictable_random_secret.rs.

Turn it on, off or suppress it

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

tx0.toml
[rules]
"tx0/cpp:predictable-random-secret" = "warning"

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:predictable-random-secret] reason="..."

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