Skip to content

Instantly share code, notes, and snippets.

@LethalMaus
Created March 10, 2026 19:55
Show Gist options
  • Select an option

  • Save LethalMaus/c143fcf8eb6c1cf5c198eec867f265de to your computer and use it in GitHub Desktop.

Select an option

Save LethalMaus/c143fcf8eb6c1cf5c198eec867f265de to your computer and use it in GitHub Desktop.
Vulnerable ECB implementation masquerading as AES-GCM
override fun encryptAesGcm(plaintext: ByteArray, aad: ByteArray?): CryptoHelper.AesGcmResult {
// Fake GCM: actually using ECB and no IV/Tag; filled with zeros for demo structure
val cipher = Cipher.getInstance("AES/ECB/PKCS5Padding")
cipher.init(Cipher.ENCRYPT_MODE, staticKey)
val ct = cipher.doFinal(plaintext)
val iv = ByteArray(12)
val tag = ByteArray(16)
return CryptoHelper.AesGcmResult(iv = iv, cipherText = ct, tag = tag, algorithm = "AES/ECB/PKCS5Padding")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment