A cipher is created with a broken algorithm or ECB mode
What it finds
Cipher.getInstance("DES"), "RC4" or "AES/ECB/PKCS5Padding" encrypt weakly: DES and RC4 are broken, and ECB encrypts equal blocks to equal output, which shows patterns of the plain text. "AES" alone means ECB on the JVM. AES in GCM mode is the usual choice.
From the rule's source, weak_cipher.rs.
import javax.crypto.Cipher fun ciphers() { val a = Cipher.getInstance("DES/CBC/PKCS5Padding")tx0 reports: uses a broken algorithm val b = Cipher.getInstance("AES/ECB/PKCS5Padding")tx0 reports: uses ECB mode val c = Cipher.getInstance("AES")tx0 reports: uses ECB mode val d = Cipher.getInstance("AES/GCM/NoPadding")} 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:weak-cipher" = "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:weak-cipher] reason="..."tx0 explain tx0/kotlin:weak-cipher shows the same in the terminal. Found a false positive? Report it.