· via Hacker News – Front Page (native)
Malformed Base64 input enables remote code execution in OpenJDK's x86-64 decoder
A researcher demonstrates how a miscalculated store mask in an OpenJDK Base64 intrinsic turns malformed input into an out-of-bounds write, a heap leak and full remote code execution.

What happened
A security researcher has published a full exploit chain for remote code execution in OpenJDK, triggered by nothing more exotic than malformed Base64 input. The author, Quang Luong, dubbed the issue "Java4Shell" in a write-up on calif.io that reached the front page of Hacker News. The root cause is an out-of-bounds write in HotSpot's x86-64 Base64 intrinsic which, on affected builds, can be escalated through heap manipulation into memory disclosure and arbitrary code execution.
Inside the bug
Intrinsics are hand-optimized routines in which the JVM uses specialized CPU instructions to beat what ordinary compiled code can do. According to the write-up, the x86-64 Base64 intrinsic walks the input in 256-byte blocks, then 64-byte blocks, and for inputs shorter than 64 bytes it relies on the VMOVDQU8 instruction. That instruction takes a 64-bit mask that decides exactly which bytes get written to memory.
The mask arithmetic mishandles Base64 padding. The output length is derived from the input length and then decremented once for each trailing '=' character. If the remaining input takes one of several padding-heavy forms — '=', '==', 'X=', 'X==', 'XY=' or '===' — the computed output length is already zero, so the subtraction underflows to -1 or -2. A subsequent bit-masking step, faced with that underflowed value, produces an all-ones write mask, and the instruction then writes all 64 bytes regardless of the actual buffer size.
The concrete example in the write-up: a 65-byte input of 64 'A' characters followed by '=' makes the runtime allocate a 50-byte output buffer, yet 64 bytes are written starting at offset 48, past the end of the allocation. On OpenJDK 17 the code path is reached at a higher threshold, so the trigger is 128 'A' characters followed by '=' instead of 64.
From a fixed overwrite to code execution
The overwrite alone looks nearly useless. Only the first byte is fully controlled, the second partially, and bytes 2 through 63 are uncontrolled — bytes 48 to 63 are always the same value (0x9a). Only where the write lands is controllable.
The author borrowed a classic JavaScript engine exploitation technique: overwriting the length field of a neighboring array, which then keeps accepting attacker-chosen bytes. That converts the fixed overwrite into a bounded, chosen-value linear write. Corrupting a second array whose contents are copied back into a response yields an out-of-bounds read, producing a heap disclosure the author calls "JavaBleed" — potentially exposing personal data, private keys and tokens before any code execution happens.
Lining up the right neighbors requires heap grooming against the G1 garbage collector. The first layer steers allocations outside thread-local allocation buffers by tuning array sizes; the second sprays multiple array pairs to give the decoder output several possible victims, a approach the author describes candidly as spray and pray. From those primitives, the write-up repairs damaged objects to keep the JVM alive, mounts data-only attacks on application logic, and escalates to arbitrary writes reaching the Code Cache and JVM hooks for code execution.
An AI-assisted audit
The discovery story is notable in itself. Luong writes that after finishing a zero-click exploit against a phone vendor's Android runtime, he turned to OpenJDK and focused on the areas where complexity crosses boundaries: the JIT compiler, intrinsics, widely accessible APIs and cryptography. He describes delegating the audit to Codex, an AI coding agent, and says most early findings were unusable before the tool surfaced the memory corruption in the Base64 decoder.
Why it matters
Base64 decoding is everywhere in Java services — it processes tokens, uploads and API payloads — and this bug sits in the platform's optimized fast path, not in application code. A deployment can be exposed without having any flaw of its own; decoding attacker-supplied input on an affected build is enough. The impact is also staged: even attempts that stop short of code execution can leak heap contents holding secrets. The write-up is a reminder that hand-tuned intrinsic code remains a rich audit target, that AI tooling is now a working part of serious vulnerability research, and that operators running Java services should check whether their JDK build is affected and apply fixes as they become available.
- #security
- #java
- #openjdk
- #vulnerability
- #memory-safety