Dev.to WebDev 🛠 Dev 👁 0 📖 6 min read

The Java4Shell fix lives in the fourth version number

My laptop has two JDKs on Oracle's list of builds hit by Java4Shell: 27.0.1.0.3 and 21.0.13.0.3. Neither one can be hit. The builds that fix it are 27.0.1.1 and 21.0.13.1. Read those twice. The difference is one digit,

My laptop has two JDKs on Oracle's list of builds hit by Java4Shell: 27.0.1.0.3 and 21.0.13.0.3. Neither one can be hit.

The builds that fix it are 27.0.1.1 and 21.0.13.1. Read those twice. The difference is one digit, in a slot a lot of version checks throw away.

Java4Shell (CVE-2026-114938) went public on Tuesday from the security shop Calif, and it climbed to 623 points on Hacker News. It's a heap overwrite in HotSpot's hand-written AVX-512 Base64 decoder. Once the JIT has compiled the fast path, 64 A characters and one = make the stub compute a negative output length, store a full 64-byte vector anyway, and land 62 bytes past the end of a 50-byte array. Calif says it turned that into remote code execution in Keycloak, Jira, Jenkins and others, and it is holding those chains back for now.

I didn't run their trigger program. You don't need it for the question that matters today: is the JVM in front of you exposed, and what do you move to?

The fix is four lines

The patch is public in the main JDK repo as commit 5177a70, under the carefully dull title "8393212: Base64 optimization improvements". It was committed on October 13 and merged into the public repo on November 17, the day of the advisory. Here is all of it:

     __ 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

When fewer than four characters are left, the assembly now steps aside and the plain decoder finishes the job. The comment right under the new lines is my favorite part of the file. The original author explains that they meant to leave the final fragment to Java, but Java would call the routine again for every four bytes, so they handled the tail in assembly instead. That speed choice on the last few bytes is the bug, and the fix gives back exactly that much.

The fast path arrived with JDK-8268276 in June 2021 and was backported to the 17 line in November 2022, which is why Calif puts the floor at 17.0.6. The OpenJDK advisory marks 17, 21, 25 and 27 as affected and leaves 8 and 11 clear.

Where the fix landed

I resolved the newest GA tag in each OpenJDK update repo and checked that the 8393212 commit is in its history:

jdk17u  jdk-17.0.21.1-ga  has 8393212
jdk21u  jdk-21.0.13.1-ga  has 8393212
jdk25u  jdk-25.0.5.1-ga   has 8393212
jdk27u  jdk-27.0.1.1-ga   has 8393212

JEP 322 explains the shape. A JDK version is $FEATURE.$INTERIM.$UPDATE.$PATCH, and the fourth number is the patch counter, raised for a release that fixes a few critical issues. A fifth number belongs to whoever builds the JDK. So 21.0.13.0.3 is patch 0, vendor respin 3: vulnerable. 21.0.13.1 is patch 1: fixed. Amazon's fixed Corretto is 21.0.13.1.2. As K0IN put it in the HN thread: "Ofc they needed 5 version numbers."

Semver habits read three numbers: major, minor, patch. On a JDK, the third one is the update, and the real patch number falls off the end.

I found that habit in a real scanner. Semgrep published free detection scripts the same day, and they are careful work: five checks, CPU features read from the JVM itself, read-only cloud probes. Its version key keeps only the first three numbers, though. I retyped that rule in Python to see what it does with this week's strings:

21.0.13.0.3  -> 21000013   vulnerable
21.0.13.1    -> 21000013   fixed
21.0.13.1.2  -> 21000013   fixed (Corretto)
27.0.1.0.3   -> 27000001   vulnerable
27.0.1.1     -> 27000001   fixed

Same key on both sides of the fix. In the copy I read, written about an hour before disclosure when no fix was public, that only makes a patched 21.0.13.1 show as impacted. Noisy, but safe. The quiet failure comes next. Its README says to add a version to the fixed list once a release ships with the fix. Add 21.0.13.1, and an unpatched 21.0.13.0.3 compares equal and reads as fixed.

Java already compares these the right way, so let Java do it:

$ jshell -q
jshell> Runtime.version()
$1 ==> 27.0.1.0.3
jshell> Runtime.Version.parse("21.0.13.1").compareTo(Runtime.Version.parse("21.0.13.0.3"))
$2 ==> 1

The version isn't the exposure either

That's why my laptop is fine. All of these have to be true at once:

  • an x86-64 JVM on a CPU with AVX-512 VBMI (Calif names Intel Ice Lake and later server chips, and AMD Zen 4 and later);
  • HotSpot, with C2 compiling the decoder so the stub actually runs;
  • a version from 17.0.6 up to the fix.

My M1 Max fails the first one. What surprised me was the flag people grep for. UseBASE64Intrinsics reads true on all three of my JDKs, ARM and JDK 11 included. On x86 it is on by default whenever AVX2 is there, too. In the source, the stub decides on the AVX-512 path once, when HotSpot generates it, and only if the CPU reports VBMI, BW and BMI2. So "intrinsic on" tells you nothing by itself.

Ask the JVM what it sees, since a hypervisor can hide CPU features from a guest:

$ java -Xlog:os+cpu=info -version 2>&1 | grep -o avx512_vbmi
$ java -XX:+PrintFlagsFinal -version | grep -E 'UseAVX|UseBASE64Intrinsics'

On x86, the bad combination is avx512_vbmi in the CPU line, UseAVX at 3 and the intrinsic on. Semgrep's README adds one I wouldn't have guessed: AWS Lambda's Java bootstrap stops the JIT at tier 1 by default, so C2 never compiles the decoder there unless you change the tiering.

What I'd do today

Move to a build that carries the fix: OpenJDK 17.0.21.1, 21.0.13.1, 25.0.5.1 or 27.0.1.1, or your vendor's build on top of them. Corretto shipped Tuesday. Homebrew moved openjdk, openjdk@21 and openjdk@17 the same evening. Temurin hadn't when I checked late Tuesday: Adoptium's API still listed 21.0.13+9, from October 22, as the newest 21. JDK 26 gets nothing. Its update repo is archived and its last tag dates from August, so the way out is 27.0.1.1.

Where you can't upgrade yet, Calif offers two flags. I tried both on my ARM JDK:

$ java -XX:UseAVX=2 -version
Unrecognized VM option 'UseAVX=2'
Error: Could not create the Java Virtual Machine.

$ java -XX:-UseBASE64Intrinsics -version
openjdk version "27.0.1.0.3" 2026-10-24

Calif's page does warn about the first one, but seeing it fail is different. Roll UseAVX=2 out to every JVM in a fleet that has ARM hosts in it and you take down the ARM half yourself. The HN thread spent a long subthread on exactly that. -XX:-UseBASE64Intrinsics starts everywhere.

Whichever you do, read the version the running process reports, all of it, and compare with Java's rules rather than a three-number key.

Thinner than the headline

Calif scores it 9.2 under CVSS 4.0. OpenJDK and Oracle score it 8.1 under CVSS 3.1, with attack complexity marked High. Calif's own limitations section shows why. There is no universal payload, each app needs its own heap-grooming profile, the timing is touchy enough that they rented a VM in the target's region, and a proxy that buffers whole request bodies (nginx does by default) breaks some chains, though not the Elasticsearch one. On HN, tptacek called a memory corruption bug in Java's core Base64 handling wild, and still not as bad as Log4Shell. I agree with both halves.

The part I'd watch is the client side. Calif says a Java program that merely opens a TLS connection to a malicious server can be compromised too. As I read it, that pulls in anything making outbound calls: CI jobs, build tools, crawlers. Not just servers.

How does your inventory store a JDK version: the full string the JVM reports, or three numbers parsed out of it?

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.