Skip to content
Memory corruption Write-up Advanced

Java4Shell, Reproduced on a CPU That Doesn’t Exist

A heap overwrite exists in OpenJDK's AVX-512 Base64 decode intrinsic, where a malformed padded input causes the vector path to write past the output array. An attacker who can supply such input to a decode endpoint on AVX-512-capable hardware could corrupt heap memory with a fixed, predictable value.

Raj Namdev Follow

Published on medium.com

My laptop is a 13th-generation Intel i5 running vulnerable OpenJDK 21.0.13 — the exact affected build — and the trigger is the one Calif published: 64 A characters and one =. It does nothing here.

Raj Namdev, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the vectorised decode stub's padding branch underflows the output mask for tails shorter than one complete block, so the store writes the decode of the stub's own dummy data past the array.

Impact

On AVX-512-capable hosts the write could corrupt a neighbouring array's length field and allow heap read-back, though the author's reproduction was emulated and no real-world compromise is confirmed.

What the attacker needed

CPU with avx512vbmi and avx512bw; affected JDK build (17, 21, 25 or 27); decoder hot enough for C2 compilation; attacker-controlled base64 reaches java.util.Base64

The fix

The fix was shipped: tails shorter than one complete block are routed to the scalar path so they never enter the vulnerable vector tail.

How it was found

  1. Run the public trigger on a CPU without the AVX-512 flags and observe no change.
  2. Run the same affected JDK under an Intel CPU emulator presenting a Sapphire Rapids CPUID.
  3. Force synchronous compilation so the decoder is C2-compiled.
  4. Send the malformed padded input and observe bytes changed past the array.
  5. Repeat with the fixed JDK build and with the mitigation flags to confirm no change.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

Base64 is a way of packing binary data into plain text characters, and Java has a fast built-in routine for decoding it. On certain modern processors that routine has a bug: when it is handed a slightly malformed string, it writes extra bytes into memory beyond the space it was given. That can let someone who controls the input disturb other data in the program.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by Raj Namdev

View all

9 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.