Skip to main content0xAdham

Command Palette

Search for a command to run...

0xL4ugh CTF v5 — Cracking AES with a Multimeter: Side-Channel Analysis

Written by
Avatar of 0xAdham
0xAdham
Published on
--
0xL4ugh CTF v5 — Cracking AES with a Multimeter: Side-Channel Analysis

Event: 0xL4ugh v5 CTF Category: Hardware Challenge: SCA1 (Side-Channel Analysis 1)

We're taught that AES-128 is a digital fortress. 10 rounds. 2¹²⁸ key space. The math holds. The implementation doesn't.

This is how I broke AES without touching a single line of the algorithm.


Files Provided

  • plaintexts.npy — 10,000 inputs fed to a black-box AES core
  • traces.npy — Power consumption measurements during each encryption

No source code. No debugger. No cryptographic oracle. Just power traces.


The Physics of Betrayal

AES doesn't run on math. It runs on transistors — physical devices consuming physical power to flip physical bits. Power consumption isn't constant. It varies with the data being processed.

This is a side-channel: an unintended information leak through the physical implementation. The specific leak here is Hamming weight correlation:

More 1 bits in a value → more gates switching → more current drawn.

Simple. Devastating.


The Attack: Correlation Power Analysis (CPA)

CPA correlates predicted power consumption against measured traces statistically.

Target

Round 1, SubBytes — the first S-Box lookup:

We control the plaintext. We measure the power. The key enters linearly through XOR.

Hypothesis

For each of the 16 key byte positions and each possible value (0–255), predict power consumption using Hamming weight:

A 256 × 10,000 matrix of predictions per byte position.

Correlation

For each time sample in the traces, compute the Pearson correlation between predictions and reality:

  • Wrong guess: ρ ≈ 0 — model and reality are strangers
  • Correct guess: ρ → 1 at the exact clock cycle of S-Box execution — a spike, the electromagnetic fingerprint of the secret byte

The Code

16 iterations. 4,096 correlations. Sub-second execution.


Output

ASCII: DPA4BabyGogoGaga

Correlations above 0.77 across all bytes. Statistical certainty.


Why It Works

FactorExplanation
Linear key mixingXOR allows byte-by-byte isolation in Round 1
Deterministic leakageHamming weight approximates power consumption
Independent noiseAveraging 10,000 traces reduces variance as 1/√N
No countermeasuresNo masking, hiding, or shuffling implemented

After ~1,000 traces the correct key byte's correlation dominates. At 10,000 it's cryptographic certainty.


The Bigger Picture

This isn't a CTF trick. This is Differential Power Analysis, published by Kocher et al. in 1999, now standard in hardware security certification (Common Criteria, FIPS 140-2/3). Smart cards, TPMs, Apple Secure Enclave, Qualcomm SPU — everything gets this treatment.

Real-world countermeasures:

  • Masking — split sensitive values into random shares
  • Hiding — randomize execution order, inject power noise
  • Shuffling — permute S-Box access patterns

None were present here.


Flag

The math of AES remains unbroken. The physics of AES is an open book.


— 0xAdham | RootRunners

Edit on GitHub
Last updated: --