Find reused GCM and CCM initialization vectors

Proprietary

Finds Cipher#init calls in Cipher.ENCRYPT_MODE with a GCMParameterSpec, and BouncyCastle GCM and CCM init(true, ..) calls with AEADParameters, whose initialization vector is built from literals only (CWE-323). Encrypting twice with the same key and IV in a counter mode exposes the plaintext and lets an attacker forge messages. Generate a new IV for every encryption, for instance with SecureRandom. Test sources are not searched.

org.openrewrite.java.security.search.FindReusedCounterModeIv
mod run . --recipe=org.openrewrite.java.security.search.FindReusedCounterModeIv

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.