An initialization vector is written in the code, so every encryption reuses it
What it finds
IvParameterSpec(byteArrayOf(0, 1, 2, ...)) or IvParameterSpec("0000000000000000".toByteArray()) uses the same vector for every message, so equal messages encrypt equally, and in modes such as GCM reuse breaks the encryption outright. A fresh random vector per message, sent with it, is needed.
From the rule's source, constant_iv.rs.
import javax.crypto.spec.IvParameterSpec fun specs(random: ByteArray) { val a = IvParameterSpec(byteArrayOf(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15))tx0 reports: the initialization vector is a constant val b = IvParameterSpec("0000000000000000".toByteArray())tx0 reports: the initialization vector is a constant val c = IvParameterSpec(random)} 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/kotlin:constant-initialization-vector" = "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/kotlin:constant-initialization-vector] reason="..."tx0 explain tx0/kotlin:constant-initialization-vector shows the same in the terminal. Found a false positive? Report it.