← Back

Padding Oracle Attack

Exploiting error messages to decrypt CBC ciphertext

⚠️ Educational Demonstration

This attack was discovered in 2002 and has been used against SSL, ASP.NET, and many other systems. Never implement your own crypto without authenticated encryption (like AES-GCM)!

How It Works

In CBC mode, PKCS#7 padding is added to make plaintext a multiple of block size. Valid padding ends with:

...01 | ...02 02 | ...03 03 03 | ...04 04 04 04 | etc.

A "padding oracle" is any system that tells you whether decrypted padding is valid. By manipulating ciphertext bytes and observing responses, we can decrypt one byte at a time without knowing the key!

Live Attack Simulation

Ciphertext Block (16 bytes)
Waiting...
Attack Progress 0%
Recovered Plaintext:
????????????????
0
Bytes Recovered
0
Oracle Queries
-
Avg Queries/Byte

Defense: Authenticated Encryption

Modern systems should use AEAD (Authenticated Encryption with Associated Data) modes like:

AES-GCM: Combines encryption with authentication tag

ChaCha20-Poly1305: Stream cipher with MAC

These modes detect tampering before decryption, eliminating padding oracles entirely.