Why it matters
Data encrypted with these ciphers can be recovered by an attacker who captures enough of it, so the encryption no longer keeps it confidential.
How to fix it
Use Cipher.getInstance("AES/GCM/NoPadding") with a random 12-byte IV.
Example
The rule's own test fixtures, verbatim: the test suite requires the rule to report the first and not the second.
import javax.crypto.Cipher;
public class Bad {
public Cipher cipher() throws Exception {
return Cipher.getInstance("DES/CBC/PKCS5Padding");
}
}import javax.crypto.Cipher;
public class Ok {
public Cipher cipher() throws Exception {
return Cipher.getInstance("AES/GCM/NoPadding");
}
}What TrustIvan reads
Runs on repository scans of Java source once static analysis is turned on (SAST_RULES and the separately built analyzer image); it is off by default.
Weakness classes and references
Related checks
- XXE XML input factory (Java)
JavaSeverity: High
trustivan-java-xxe-xml-input-factory - ECB mode (Java)
JavaSeverity: High
trustivan-java-ecb-mode - XXE document builder (Java)
JavaSeverity: High
trustivan-java-xxe-document-builder - Insecure random secret (Java)
JavaSeverity: Medium
trustivan-java-insecure-random-secret - SQL string concatenation (Java)
JavaSeverity: Medium
trustivan-java-sql-string-concatenation - Trust all certificates (Java)
JavaSeverity: High
trustivan-java-trust-all-certificates
Terms: SAST (static application security testing), Taint analysis, CWE (Common Weakness Enumeration), OWASP Top 10
All static analysis (SAST) checks · The whole catalogue · How this works in TrustIvan · Documentation