Articles Java

Java4Shell (CVE-2026-114938): check and fix your Java app

Java4Shell (CVE-2026-114938) is a memory corruption bug in the JVM itself, in the code that decodes Base64. You are affected if you run Java 17.0.6 or later, 21, 25 or 27 on an x86-64 CPU with AVX-512 VBMI. The fix is a JDK update: 17.0.21.1, 21.0.13.1, 25.0.5.1 or 27.0.1.1. If you cannot update today, start the JVM with -XX:-UseBASE64Intrinsics.

The rest of this article shows how to check each of those things on a real system, and what went wrong when I patched Yocora, so you can skip those mistakes.

What is Java4Shell, in plain terms

java.util.Base64 is ordinary Java code, but HotSpot replaces its hot loop with hand-written machine code once the JIT compiler decides the method is used often. On CPUs with AVX-512 VBMI that replacement decodes 64 characters at a time.

The bug is in how that fast path handles the end of the input. For input with badly placed = padding, the computed output length goes below zero, and the routine writes a full 64-byte block where only a few bytes fit. The result is a write of about 62 bytes past the end of a Java array on the heap. Base64.Decoder then throws IllegalArgumentException, as it should for bad input, but the damage is already done.

Three facts make this serious:

  • It is not a library you can remove from the classpath. Every application on an affected JVM has it.
  • The input is attacker-controlled almost everywhere. Authorization: Basic headers, JWTs, cookies and file uploads are all Base64 that your server decodes before it knows who is asking.
  • It needs no unusual configuration. A busy service compiles the decoder within minutes of starting.

How bad is it in practice? The researchers who reported it (Calif) say they reached remote code execution in several well-known products. The proof of concept that is public corrupts memory and crashes the JVM, and independent analysts describe a crash as the outcome that is easy to reach, with code execution depending on the application. Oracle scores it 8.1 (CVSS 3.1), Calif 9.2 (CVSS 4.0). Either way, an unauthenticated request that can take your service down is enough reason to patch.

Are you affected? Check the JDK version and the CPU

Both conditions must hold.

The JDK version. Run this where the application runs, not on your laptop:

docker exec <container> java -version
Java lineAffectedFixed in
8 and 11No (standard builds)-
1717.0.6 to 17.0.2117.0.21.1
21up to 21.0.1321.0.13.1
25up to 25.0.525.0.5.1
27up to 27.0.127.0.1.1

Non-LTS lines that are out of support (18 to 20, 22 to 24, 26) get no fix. Move to a supported line.

The CPU. The fast path needs four CPU features. This prints the ones your machine has:

grep -o -w -E 'avx512f|avx512bw|avx512vbmi|bmi2' /proc/cpuinfo | sort -u

If all four are listed, the vulnerable code can run. That means Intel Xeon from Ice Lake onwards and AMD from Zen 4 onwards. ARM64 is not affected. A container sees the CPU of its host, so run the command anywhere on that machine.

My advice: do not stop at “our CPU does not have it”. In the cloud the CPU under your instance changes when you resize, migrate or let an autoscaler pick a newer family. The JDK update is cheap and removes the question.

How to fix it: update the JDK

Update to the fixed version of your line and restart. With Docker that is one line in the Dockerfile:

FROM eclipse-temurin:21.0.13.1_2-jdk

After the deploy, ask the running container, because that is the only answer that counts:

docker exec <container> java -version
openjdk version "21.0.13.1" 2026-11-17 LTS
OpenJDK Runtime Environment Temurin-21.0.13.1+2 (build 21.0.13.1+2-LTS)

Temurin, Corretto, Zulu, Oracle and the Debian, Ubuntu and Red Hat packages all have fixed builds. The version string differs slightly per vendor, so compare against your vendor’s notice.

If you cannot update today: the JVM flag

This turns the fast Base64 code off, and the JVM falls back to the plain Java implementation:

java -XX:-UseBASE64Intrinsics -jar app.jar

In a container it is usually easier to set it through the environment:

JAVA_TOOL_OPTIONS=-XX:-UseBASE64Intrinsics

The JVM confirms it at startup with Picked up JAVA_TOOL_OPTIONS: -XX:-UseBASE64Intrinsics. To see the effective value:

java -XX:-UseBASE64Intrinsics -XX:+PrintFlagsFinal -version | grep UseBASE64Intrinsics
bool UseBASE64Intrinsics = false {product} {command line}

Base64 decoding gets slower. For a typical web application that decodes a header per request you will not notice; measure if you decode large payloads all day. Some guides suggest -XX:UseAVX=2 instead. It works, but it switches off every AVX-512 optimisation in the JVM, not only this one.

Treat the flag as a bridge to the update, not as the fix.

Three mistakes that leave you exposed after you “patched”

All three come from patching Yocora.

1. The rebuild reused an old base image

Our Dockerfile said FROM eclipse-temurin:21-jdk. Rebuilding does not download that tag again if the build host already has it. On my own machine, days after the fix was released, that tag still gave me this:

openjdk version "21.0.11" 2026-04-21 LTS

A green deploy, and the same vulnerable JVM. Pin the full version in FROM, as in the example above, or build with docker build --pull. Pinning is better: the Dockerfile then states which JDK you run, and the next security update is a visible one-line change.

2. The flag has an unusual spelling

It is UseBASE64Intrinsics, with BASE64 in capitals. Write it the way Java names usually look and the JVM refuses to start:

Unrecognized VM option 'UseBase64Intrinsics'
Did you mean '(+/-)UseBASE64Intrinsics'?
Error: Could not create the Java Virtual Machine.

Put that typo in the environment of a production service and you have turned a security fix into an outage. Try the exact flag with java -version on the same image before you deploy it.

3. The JVMs you forgot

JAVA_TOOL_OPTIONS only reaches a JVM that sees that environment variable. Yocora runs code submitted by learners in separate JVMs, and the code that starts them clears the environment first, on purpose. The flag on the API container never reached them. Those processes also ran from a different image, which needed its own update.

List every place a JVM starts in your system: the application, workers, scheduled jobs, sandbox or build images, and anything started with ProcessBuilder. Each one needs the update, or the flag on its own command line.

Checklist

  1. Find every JVM you run, including child processes and secondary images.
  2. Check java -version inside each running container against the table above.
  3. Check the CPU flags on the host, but do not rely on them staying the same.
  4. Update the JDK, with the full version pinned in FROM.
  5. Until then, set -XX:-UseBASE64Intrinsics, spelled exactly, on every JVM.
  6. After the deploy, run java -version in the running container again.
  7. Remove the flag once every JVM is on a fixed version.

Sources