Scala Insecure Aes Cipher Mode
Description
This vulnerability detector identifies insecure AES cipher modes in Scala code. When developers use weak cipher modes like ECB (Electronic Code Book), it exposes patterns in encrypted data that can be exploited by attackers to recover plaintext information, compromising data confidentiality.
Detection Strategy
• Scans for method calls to 'getInstance' on the 'Cipher' class in Scala code
• Examines the first argument passed to the getInstance method to determine the cipher transformation
• Reports a vulnerability when the cipher transformation specifies an insecure AES mode (typically ECB mode or other weak configurations)
• Triggers when code patterns like 'Cipher.getInstance("AES/ECB/PKCS5Padding")' are found, indicating use of vulnerable encryption modes
Vulnerable code example
import javax.crypto.Cipher
object VulnerableExample {
def encryptData(): Cipher = {
Cipher.getInstance("AES/CBC/NoPadding") // Vulnerable: CBC mode lacks authentication
}
def encryptSession(): Cipher = {...✅ Secure code example
import javax.crypto.Cipher
object SecureExample {
def encryptData(): Cipher = {
Cipher.getInstance("AES/GCM/NoPadding") // Secure: GCM provides authentication
}
def encryptSession(): Cipher = {...Search for vulnerabilities in your apps for free with Fluid Attacks' automated security testing! Start your 21-day free trial and discover the benefits of the Continuous Hacking Essential plan. If you prefer the Advanced plan, which includes the expertise of Fluid Attacks' hacking team, fill out this contact form.