Skip to content
Huseyin Babal
Go back

Java4Shell (CVE-2026-114938): the Base64 intrinsic bug, and how to check your JVM

CVE-2026-114938, which Calif.io calls Java4Shell, is a memory corruption bug in HotSpot’s hand-written x86-64 Base64 decoder. OpenJDK fixed it on November 17, 2026. This post covers who runs the affected code, how to check a server, the switch that turns the code off, which builds have the fix, and how the bug works. It contains no exploit and no input that triggers it.

Build availability below was read on November 18 and 19, 2026. Check the sources for the current state.

Who is affected

Three conditions have to be true at the same time:

ConditionDetail
Java versionOpenJDK 17, 21, 25 or 27 before the fixed builds. Calif puts the start at 17.0.6. Java 8 and 11 are not listed
CPUx86-64 with AVX-512 VBMI: Intel Xeon Ice Lake and newer (Sapphire, Emerald, Granite Rapids), AMD Zen 4 and newer
InputBase64 that an outside party controls reaches java.util.Base64 decoding, and the decoder is hot enough for the JIT to use the intrinsic

Every distribution built from OpenJDK carries the code: Temurin, Corretto, Zulu, Liberica, SapMachine, the Microsoft and Red Hat builds, and Oracle’s own. ARM64 servers (Graviton, Ampere) and Apple Silicon Macs never run it: the faulty routine is part of HotSpot’s x86-64 backend, and Calif lists ARM64 as not affected.

The OpenJDK advisory scores it 8.1 with CVSS 3.1 (attack complexity high). Calif scores it 9.2 with CVSS 4.0.

Check a server in three steps

I ran these on a DigitalOcean droplet. First, the CPU. The intrinsic needs all four of these flags:

grep -m1 'model name' /proc/cpuinfo
grep -m1 '^flags' /proc/cpuinfo | tr ' ' '\n' | grep -E '^(avx512f|avx512bw|avx512vbmi|bmi2)$'
model name      : Intel(R) Xeon(R) Platinum 8358 CPU @ 2.60GHz
bmi2
avx512f
avx512bw
avx512vbmioutput

All four are present, so the AVX-512 decoder can run here. Fewer than four lines means the JVM uses a different decoder on this machine.

Second, the Java version:

java -version
openjdk version "27.0.1.0.2" 2026-10-21
OpenJDK Runtime Environment Temurin-27.0.1.0.2+1 (build 27.0.1.0.2+1)
OpenJDK 64-Bit Server VM Temurin-27.0.1.0.2+1 (build 27.0.1.0.2+1, mixed mode, sharing)output

The advisory names 27.0.1.0.3 and everything before it as affected, so this runtime is.

Third, ask the JVM whether the intrinsic is on:

java -XX:+PrintFlagsFinal -version | grep -i base64 | tr -s " "
 bool UseBASE64Intrinsics = true {product} {default}output

true on a machine that passed the first check means the vulnerable path is live.

In containers, run the second and third command inside the container. The host’s Java says nothing about the runtime in your image.

Fixed builds

The fix is in these OpenJDK releases (the patch line is present at each tag):

LineFixed releaseTemurin buildPublished (UTC)
2727.0.1.127.0.1.1+4Nov 18, 10:09
2525.0.5.125.0.5.1+2Nov 18, 21:05
2121.0.13.121.0.13.1+2Nov 18, 21:07
1717.0.21.117.0.21.1+2Nov 18, 20:39

After an update, the version line changes:

./jdk/bin/java -version
openjdk version "27.0.1.1" 2026-11-17
OpenJDK Runtime Environment Temurin-27.0.1.1+4 (build 27.0.1.1+4)
OpenJDK 64-Bit Server VM Temurin-27.0.1.1+4 (build 27.0.1.1+4, mixed mode, sharing)output

For other vendors, compare against the fixed OpenJDK release above or the vendor’s own advisory. Their version strings don’t always follow OpenJDK’s.

Docker images lag behind

When I listed the official eclipse-temurin tags on Docker Hub late on November 18, the newest ones were still 27.0.1.0, 25.0.5_8, 21.0.13_9 and 17.0.21_9, all older than the fixed builds. A floating tag like eclipse-temurin:21 only helps once it is rebuilt, and a pinned one like eclipse-temurin:21.0.13_9-jre never moves. Check the version inside the image you actually deploy:

docker run --rm your-image:tag java -version

If you can’t update today

Turn the intrinsic off. The JVM then falls back to the plain Java decoder:

java -XX:-UseBASE64Intrinsics -XX:+PrintFlagsFinal -version | grep -i base64 | tr -s " "
 bool UseBASE64Intrinsics = false {product} {command line}output

{command line} confirms the setting came from your flag. For a container or a service you don’t start by hand, JAVA_TOOL_OPTIONS=-XX:-UseBASE64Intrinsics passes it to every JVM that starts in that environment.

Calif’s write-up also mentions -XX:UseAVX=2, which disables AVX-512 in the JVM entirely. It switches off every AVX-512 code path in the JVM, not only Base64. The flag only exists on x86-64, so a JVM on ARM refuses to start with it. Don’t put it in a shared image that runs on both.

Remove the flag once you’re on a fixed build.

How the bug works

java.util.Base64.Decoder is ordinary Java code. When a method runs often, HotSpot’s C2 compiler turns it into machine code, and for a few methods it goes further and swaps in a routine written by hand in assembly. Those routines are called intrinsics. The Base64 decoder has one, and on CPUs with AVX-512 VBMI it handles 64 input characters per round: one load, a few instructions to decode, one store of 48 bytes.

The trouble is the end of the input. When 1 to 63 characters are left, the routine builds a store mask, one bit per output byte, so that only bytes inside the destination array get written. Here is the vulnerable code from stubGenerator_x86_64.cpp (OpenJDK 27.0.1.0.3):

__ 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));
...
__ BIND(L_padding);
__ decrementq(output_size, 1);
...
__ movq(output_mask, -1);
__ bzhiq(output_mask, output_mask, output_size);

It computes (length / 4) * 3 for the tail, then subtracts one for each = padding character. Take a tail that is shorter than four characters and ends in =. Integer division gives zero, so the output size starts at 0. The padding step then makes it −1, or −2 with two =.

bzhi clears every bit of a register from a given position upward, and it reads that position from the low 8 bits of the index register. For −1 those bits are 255, which is past the end of a 64-bit register, so nothing is cleared. The mask stays all ones, and the masked vector store writes all 64 bytes.

The destination array was sized for the real output, which is far smaller than 64 bytes. Calif’s example ends with 62 of the 64 written bytes outside the array. Afterwards the Java code sees the input is malformed and throws IllegalArgumentException, but by then the heap next to the array has already been overwritten, and that memory belongs to other objects.

According to Calif, the overwrite can be turned into a heap memory leak and into code execution. Their write-up lists pre-authentication cases in default setups of Keycloak, Jira, Confluence, Artifactory, Jenkins and PingFederate, and post-authentication cases in Kafka, Solr, Elasticsearch, Gerrit and Spinnaker. Per Calif, each application needs its own chain, and those chains aren’t public yet. I haven’t verified those application claims.

The fix

Four lines in generate_base64_decodeBlock (merge b068723f47):

     __ BIND(L_finalBit);
     // Now have 1 to 63 bytes left to decode
 
+    // A padded Base64 tail shorter than one complete block is handled by Java.
+    __ cmpl(length, 4);
+    __ jcc(Assembler::less, L_bruteForce);
+
     // I was going to let Java take care of the final fragment

If fewer than four characters remain, the assembly stops and hands the tail back to the Java code, which checks the padding properly. The output size can no longer start at zero and go negative. The comment just below the fix is the original reason the tail is handled in assembly at all: calling back into Java for every four bytes would be slow. The fix keeps that for longer tails and only hands the shortest ones back to Java.

Sources


Share this post:

Previous Post
Rust vs C++ on the same LLVM: four programs, one 16-core server
Next Post
nginx2root (CVE-2026-123007): the HTTP/2 window bug, and how to check your nginx