cd /news/artificial-intelligence/why-ecb-mode-leaks-penguins-and-why-… · home › topics › artificial-intelligence › article
[ARTICLE · art-182740] src=dev.to ↗ pub= topic=artificial-intelligence verified=true sentiment=· neutral

Why ECB Mode Leaks Penguins and Why AEAD (AES-GCM) Matters for API Payloads

A developer explains why AES in ECB mode leaks plaintext structure—identical 16-byte blocks produce identical ciphertext, preserving patterns in JSON and images—and why modern APIs should use AEAD ciphers like AES-256-GCM or ChaCha20-Poly1305, which add integrity verification and prevent padding-oracle attacks. The writeup includes a TypeScript Web Crypto example that binds a tenantId to an encrypted payload via additionalData, so a ciphertext moved between tenants fails authentication on decrypt.

recommendation

Encrypt API payloads with AES-256-GCM and bind routing metadata like tenantId as additionalData so tampered or relocated ciphertext fails verification before decryption.

more in playbook: Securing agents and AI tools
by read1 min views5 publishedDec 6, 2026

If you have ever seen the famous "ECB penguin" picture in a cryptography textbook, you already know why block cipher modes matter.

When you encrypt data with AES in Electronic Codebook (ECB) mode, identical 16-byte plaintext blocks produce identical 16-byte ciphertext blocks. That means patterns in structured data, JSON keys, or bitmap pixels survive encryption completely intact.

In 1949, Claude Shannon showed that strong encryption requires diffusion: flipping a single plaintext bit should scramble the entire ciphertext output. ECB violates diffusion across blocks because every 128-bit block is encrypted independently.

Even worse, ECB and older modes like CBC provide confidentiality without built-in integrity. If an attacker flips bits in transit, your server tries to decrypt tampered bytes and can leak information through padding error messages (a padding oracle attack).

AES-256-GCM) Solves Both Problems Modern APIs and TLS 1.3 rely on Authenticated Encryption with Associated Data (AEAD) such as AES-256-GCM or ChaCha20-Poly1305:

additionalData) fails verification immediately before decryption returns plaintext. Here is how you bind unencrypted routing metadata (like a tenantId) to an encrypted payload using additionalData in TypeScript Web Crypto:

export async function encryptWithAad(
  key: CryptoKey,
  plaintext: string,
  tenantId: string,
): Promise<{ iv: Uint8Array; ciphertext: ArrayBuffer }> {
  const iv = crypto.getRandomValues(new Uint8Array(12));
  const encoder = new TextEncoder();

  const ciphertext = await crypto.subtle.encrypt(
    {
      name: "AES-GCM",
      iv,
      additionalData: encoder.encode(tenantId),
    },
    key,
    encoder.encode(plaintext),
  );

  return { iv, ciphertext };
}

Because tenantId is passed as additionalData, an attacker cannot move a valid encrypted blob from tenantA into tenantB's row without triggering an authentication failure during crypto.subtle.decrypt.

💡 Developer Infrastructure Note: Just as AEAD binds metadata to ciphertext, outbound email pipelines need cryptographically bound headers too. SadaSend pairs Dual DKIM (RFC 6376) and DMARC alignment with active Port 25 bounce checks and per-key agent spend guards.

── more in #artificial-intelligence 4 stories · sorted by recency
── more on @claude shannon 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/why-ecb-mode-leaks-p…] indexed:0 read:1min 2026-12-06 · —