
AAlves174247 (Community Member) asked a question.
I'm trying to use AES Algorithm to mitigate the CWE-327 vulnerability. Initialization Vector(IV) needs to be provided as part of this and this value needs to be randomized.
Issue: Randomizing the IV value is resulting in an incorrect decoded value because of different IV values used at the time of encryption and decryption.
Our process invokes the encrypt and decrypt operations separately, which means generating a different IV value.
Algorithm Used: AES/CBC/PKCS5Padding
Issue for both decryption and encryption.
It should only raise an issue for encryption though, since decryption requires to reuse the IV from the encryption.
No issue should be raised if Cipher.DECRYPT_MODE is passed to the first parameter of the Cipher.init method.
Cipher cipher = Cipher.getInstance(...);
cipher.init(Cipher.ENCRYPT_MODE, ks, nonrandomIv); // Noncompliant
Cipher cipher = Cipher.getInstance(...);
cipher.init(Cipher.DECRYPT_MODE, ks, nonrandomIv); // Compliant
.png)
Hi @AAlves174247 (Community Member) ,
Yes, Veracode Static Analysis will also report CWE 327 for DECRYPT_MODE. Veracode Engineering have reviewed this and determined that it is currently infeasible to detect this automatically in a performant way. They recommend documenting this as a Potential False Postive. You can read more on how to do this here: https://docs.veracode.com/r/improve_mitigation . Please note that this requires access to the Veracode Platform or the IDE plugin and you must reach out to your security team to request approval, they do not get an automatic notification.
Please also consider providing your ideas on this at https://community.veracode.com/s/ideas .
Thank you,
Boy Baukema