Skip to main content

SKY-D384 · Security in code

ECB mode selected for encryption

MediumCWE-327

Skylos reports explicit ECB selection in recognized Python ciphers and Kotlin JCA block ciphers. A detached mode value does not establish which cipher will use it.

Languages
Python, Kotlin
Quality gate
counted toward the gate limits (full and diff scans)
Finding type
review
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

ECB encrypts equal plaintext blocks to equal ciphertext blocks under the same key. The resulting patterns can reveal information about the data.

What Skylos flags

cipher.py · PythonReported on line 4
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes def make_cipher(key):    return Cipher(algorithms.AES(key), modes.ECB())

What Skylos leaves alone

cipher.py · Python
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes def make_cipher(key, nonce):    return Cipher(algorithms.AES(key), modes.GCM(nonce))

Why Skylos leaves it alone

The block cipher explicitly selects GCM. Generate a unique nonce for each encryption under a key.

More languages

Kotlin

Flagged

CipherFactory.kt · KotlinReported on line 3
import javax.crypto.Cipher as JcaCipher val cipher = JcaCipher.getInstance("AES/ECB/NoPadding")

Not flagged

CipherFactory.kt · Kotlin
import javax.crypto.Cipher as JcaCipher val cipher = JcaCipher.getInstance("AES/GCM/NoPadding")

Why Skylos leaves it alone

The explicit transformation selects authenticated encryption with GCM.

How Skylos decides

  1. Matches PyCA Cipher using its ECB mode, or Crypto and Cryptodome AES using the provider's MODE_ECB constant.
  2. In Kotlin, resolves the JCA Cipher.getInstance factory and checks the mode in a literal block-cipher transformation. Algorithm-only calls leave the mode to the provider.

How to fix it

Use an authenticated encryption API such as AES-GCM or ChaCha20-Poly1305. Follow its nonce and authentication-tag requirements.

When it can be wrong

  • A legacy interoperability path can require ECB. Check whether you control both ends and isolate the compatibility code if you cannot update the protocol.

Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.

How to silence it

  • Mark the reviewed line with a rule-scoped Skylos ignore for SKY-D384. Record the evidence that justifies the exception.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.