A cryptographic key or initialization vector is given as a string literal
What it finds
EVP_EncryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, "0123456789abcdef...", iv): a key written into the source is known to everyone who has the source or the binary, and a fixed IV makes equal messages encrypt equally. Keys come from a key store or a key derivation, IVs from a random source.
From the rule's source, literal_cryptographic_key.rs.
#include <openssl/evp.h> int start(EVP_CIPHER_CTX *ctx, const unsigned char *iv){ return EVP_EncryptInit_ex(ctx, EVP_aes_128_cbc(), NULL, (const unsigned char *)"0123456789abcdef", iv);tx0 reports: the key given to EVP_EncryptInit_ex is a string literal} 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:
[rules]
"tx0/c:literal-cryptographic-key" = "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/c:literal-cryptographic-key] reason="..."tx0 explain tx0/c:literal-cryptographic-key shows the same in the terminal. Found a false positive? Report it.