65 chars, 62 bytes past the end: I ran Java4Shell
65 characters of input. A 50-byte output buffer. A 64-byte write starting at offset 48 — 62 bytes past the end. That's Java4Shell (CVE-2026-114938), a memory-corruption bug in OpenJDK's Base64 decoder, disclosed November 17, 2026. I ran the trigger against the exact build Ubuntu still ships, read the vulnerable assembly stub in the 21.0.13 source, and measured what the optimization that introduced it actually buys you: 8.7x faster decoding.
The trigger
Calif, the firm that found it, published the trigger in the clear. On current OpenJDK builds it's 64 As followed by a single =:
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
On older OpenJDK 17 the trigger is 128 As plus =. The bug lives in the AVX-512 VBMI path of the Base64 intrinsic — the hand-written assembly stub HotSpot uses to decode Base64 fast. It only fires on x86-64 CPUs with AVX-512 VBMI (Intel Ice Lake Xeon or later, AMD Zen 4 or later). My machine is an AMD EPYC 9D25, which has it, and the stock Ubuntu OpenJDK 21 I installed this morning — 21.0.13.0.3 — is exactly one patch behind the fix.
I confirmed the intrinsic was engaged before running anything: UseAVX = 3, UseBASE64Intrinsics = true by default.
What I ran, and what actually happened
The intrinsic only runs once C2 compiles the decode path, so the harness warms up first — 200,000 decodes of a valid 64-character string — then feeds the trigger 5,000 times:
Base64.Decoder dec = Base64.getDecoder();
String valid = "A".repeat(64);
String trigger = "A".repeat(64) + "=";
for (int i = 0; i < 200_000; i++) dec.decode(valid); // warm up C2
for (int i = 0; i < 5000; i++) {
try {
dec.decode(trigger);
} catch (IllegalArgumentException e) { /* expected */ }
}
Result:
warmup done
trigger length: 65
finished: caught=5000 of 5000
5,000 out of 5,000 throws. Exit code 0, no crash, no hs_err_pid log. If you were expecting a segfault, this is the honest part of the post: the trigger alone doesn't crash a bare JVM. The out-of-bounds write happens, but in a fresh harness it lands in unallocated TLAB space — memory the JVM owns but hasn't handed to any object yet. The next allocation just overwrites it. Calif's exploit needed heap grooming to place a victim object immediately after the decode buffer, then used the classic writer/reader primitives (overwrite one array's length, then read/write through it) to turn a fixed 64-byte write into arbitrary code execution. I did not build that. What I can verify, precisely, is the arithmetic that makes the write happen at all.
The arithmetic, from the source
The vulnerable code is StubGenerator::generate_base64_decodeBlock() in src/hotspot/cpu/x86/stubGenerator_x86_64.cpp (OpenJDK 21.0.13 tag). The main loop chews the input in 64-byte blocks; the tail — 1 to 63 leftover bytes — goes to L_finalBit:
__ BIND(L_finalBit);
// Now have 1 to 63 bytes left to decode
__ movq(rax, -1);
__ bzhiq(rax, rax, length); // Input mask in rax
__ movl(output_size, length);
__ shrl(output_size, 2); // Find (len / 4) * 3 (output length)
__ lea(output_size, Address(output_size, output_size, Address::times_2, 0));
// Strip pad characters, if any, and adjust length and mask
__ addq(length, start_offset);
__ cmpb(Address(source, length, Address::times_1, -1), '=');
__ jcc(Assembler::equal, L_padding);
And L_padding decrements output_size once per =:
__ BIND(L_padding);
__ decrementq(output_size, 1);
__ shrq(rax, 1);
__ cmpb(Address(source, length, Address::times_1, -2), '=');
__ jcc(Assembler::notEqual, L_donePadding);
__ decrementq(output_size, 1);
__ shrq(rax, 1);
Then the store mask is computed:
__ movq(output_mask, -1);
__ bzhiq(output_mask, output_mask, output_size);
...
__ kmovql(k1, output_mask);
__ evmovdqub(Address(dest, dp), k1, tmp, true, Assembler::AVX_512bit);
Walk the trigger through it. The input is 65 bytes. The main loop decodes the first 64 (48 output bytes) and leaves 1 byte — the =. In L_finalBit, length is 1, so output_size = (1/4)*3 = 0. The last byte is =, so L_padding decrements output_size to -1. Then bzhiq(-1, -1): BZHI zeroes the high bits starting at the count position — but the count is -1, which as an unsigned 64-bit value is far above 64, and per the Intel spec a count at or above the operand size leaves the value unchanged. So output_mask stays -1: all 64 bits set. The masked store evmovdqub then writes all 64 bytes.
Meanwhile the Java side allocated the output buffer as (ceil(65/4) * 3) - padding = 51 - 1 = 50 bytes. The store starts at dest + 48 and writes 64 bytes: 48 + 64 = 112, which is 62 bytes past the end of a 50-byte buffer. Every number in Calif's write-up checks out against the source.
One more check: I fetched the same file from the jdk21u master branch this morning. It is byte-identical to the 21.0.13 tag in this function — the fix (OpenJDK JDK-8393212) had not yet landed in the public mirror when I looked. The fixed builds are what matters: Oracle shipped them November 17.
What the optimization buys
The whole reason this assembly exists is speed. I benchmarked the same decode loop with the intrinsic on and off (48 KiB input, 200,000 iterations, best of 5, same machine):
intrinsic ON (UseBASE64Intrinsics=true): 7,299 MB/s
intrinsic OFF (-XX:-UseBASE64Intrinsics): 834 MB/s
That's an 8.7x speedup — the reason nobody questioned shipping a hand-rolled AVX-512 decoder to every Java installation on the planet. It's also the shape of the trade: an optimization most applications never needed (how much Base64 do you decode?) became the attack surface for all of them. Calif's own framing — "vibe-uncoding", delete the code you don't need — is the right moral, but the immediate fix is simpler.
Who's affected, and what to do
Per Oracle's November 2026 Critical Patch Update and the OpenJDK advisory, both November 17:
Affected: OpenJDK 17.0.6 and later, and 21, 25, 27 — any vendor build
(Oracle, Temurin, Corretto, Zulu, Microsoft Build of OpenJDK)
on x86-64 CPUs with AVX-512 VBMI. Java 8 and 11 are NOT
affected (except Oracle's 8u511b33-perf Enterprise Performance Pack).
Not fixed: Java 18–20, 22–24, 26 are end-of-life and will not get a fix.
Fixed: 17.0.21.1 / 21.0.13.1 / 25.0.5.1 / 27.0.1.1
My Ubuntu box is the proof that "fixed" and "installed" are different things: apt installed 21.0.13.0.3 this morning, and as of November 18 the Ubuntu/Debian packages with the fix were still pending. If you can't patch yet, one JVM flag closes the exposure: -XX:-UseBASE64Intrinsics. It costs you the 8.7x — which, for most services, is nothing at all.
Scores: Calif rates it 9.2 under CVSS 4.0; Oracle rates it 8.1 under CVSS 3.1. Calif claims pre-auth RCE in Keycloak, Jira, Confluence, Artifactory, Jenkins, and PingFederate in default configs, and post-auth RCE in Kafka, Solr, Elasticsearch, Gerrit, and Spinnaker — but is withholding the per-application exploits for now. CISA issued an alert on November 17 urging immediate patching. As of November 17, no exploitation in the wild had been publicly confirmed.
The uncomfortable part isn't the bug. It's the shape of it: a memory-safety hole in the one language people pick specifically for memory safety, hiding in an optimization for a format most programs decode a few hundred bytes of at a time. Sixty-five characters in, sixty-two bytes out of bounds, and the only thing standing between the two was a bzhiq count nobody checked could go negative.
Sources: Calif, "Java4Shell: Write once, RCE everywhere" (Nov 17, 2026); OpenJDK stubGenerator_x86_64.cpp, jdk-21.0.13-ga, generate_base64_decodeBlock(); CISA alert, Nov 17, 2026; Qualys, "How to Find, Mitigate, and Patch the Critical Java4Shell Flaw"; IONIX, Java4Shell affected versions and fix. Trigger runs, throughput numbers, and the source diff are my own measurements on this machine (AMD EPYC 9D25, Ubuntu OpenJDK 21.0.13.0.3, avx512vbmi present). I did not build or run an exploit; the heap-grooming step is described from Calif's write-up.
Top comments (0)