Rules that flag potential security flaws.
Edit me
InsecureCryptoIv
Since: PMD 6.3.0
Priority: Medium (3)
Do not use hard coded initialization vector in cryptographic operations. Please use a randomly generated IV.
This rule is defined by the following Java class: net.sourceforge.pmd.lang.java.rule.security.InsecureCryptoIvRule
Example(s):
public class Foo {
void good() {
SecureRandom random = new SecureRandom();
byte iv[] = new byte[16];
random.nextBytes(bytes);
}
void bad() {
byte[] iv = new byte[] { 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, };
}
void alsoBad() {
byte[] iv = "secret iv in here".getBytes();
}
}
Use this rule by referencing it:
<rule ref="category/java/security.xml/InsecureCryptoIv" />