Earlier this week, we had to mitigate Java4Shell (CVE-2026-114938) in some Java applications. Adding a JVM flag was the easy part. Understanding why a Base64 decoder needed a security mitigation in the first place? Well, that's where I started asking questions.

I know Java. I know Base64. And I thought Java was supposed to protect me from writing outside an array. So how did we get here?

Let's go through it without assuming we all read JVM assembly for fun. :)

The vulnerability was disclosed on November 17, 2026. It's in an optimized Base64 decoding routine in HotSpot, and under specific conditions it can corrupt JVM heap memory. Researchers demonstrated remote code execution (RCE) in several Java products, but that doesn't mean any malformed Base64 string will execute code in every Java application.

Sources: Calif, the original research; Group-IB's assessment.

TL;DR — What happened?#

Java4Shell (CVE-2026-114938) is a vulnerability in HotSpot, the JVM implementation used by OpenJDK-based distributions.

To make Base64 decoding faster, HotSpot uses special CPU instructions on certain processors. Unfortunately, there's a bug in that optimized implementation.

With specially malformed Base64 input, the decoder can miscalculate the output size and write beyond its allocated memory. In one documented example, that's 62 extra bytes.

This can crash the JVM or, under specific conditions, allow an attacker to execute code.

The fix? Update to a patched JDK. If that's not possible immediately, disable the vulnerable optimization:

bash
-XX:-UseBASE64Intrinsics

Running Java in Docker? Make sure the flag actually reaches your running JVM. Here's how to check with JConsole.

Sources: Calif's original research; Group-IB's assessment; Adoptium's vendor guidance.

First, Base64. Nothing fancy.#

Base64 is a way of representing binary data as text. It's encoding, not encryption.

For example, SGVsbG8= is Hello encoded as Base64. In Java:

java
byte[] decoded = Base64.getDecoder().decode("SGVsbG8=");
System.out.println(new String(decoded, StandardCharsets.UTF_8)); // Hello

That = at the end is padding. It helps complete the final group of Base64 characters. But padding has rules: a single = on its own after a complete block isn't valid Base64.

And Base64 isn't an obscure feature. It shows up in HTTP Basic authentication, parts of tokens, SAML messages, and plenty of libraries. Your application might decode it without you ever writing the line above yourself.

Sources: Calif — overview and technical write-up; Datadog — where the decoding path can be reached.

Okay, but what exactly is HotSpot?#

Java is the language. The JDK is the toolkit for building and running Java programs. The JVM is what executes the bytecode. HotSpot is a widely used implementation of that JVM, shipped with OpenJDK-based distributions.

And where does Eclipse Temurin fit in? It's a Java distribution built by the Eclipse Adoptium project from OpenJDK source code. OpenJDK doesn't contain Temurin; Temurin is built from OpenJDK. Temurin uses HotSpot as its JVM, so a bug in HotSpot can affect Temurin too. The same idea applies to other HotSpot-based Java distributions: the vendor and the exact build matter.

Source: Eclipse Adoptium — official Temurin guidance for Java4Shell.

So when you run java -jar app.jar, there's a good chance your application is actually running inside HotSpot.

HotSpot also manages memory, runs garbage collection and optimizes code. It has a JIT compiler (just-in-time compiler) that can turn frequently executed code into optimized native instructions.

The optimizing compiler is called C2. For certain operations, such as Base64 decoding, HotSpot can substitute a special, faster native routine called an intrinsic.

Think: "I've seen this operation a lot. I know a faster CPU-level way to do it."

On supported x86-64 CPUs, the Base64 intrinsic uses instructions called AVX-512 VBMI to process lots of bytes at once. Good for performance. Not great when the bug lives in that very optimization.

Sources: Calif — The vulnerability; Akamai — how the JIT selects the fast path.

So what actually goes wrong?#

Base64 data is decoded in blocks. After the big blocks, the decoder has to handle whatever is left at the end — the tail.

Normally, it calculates how many decoded bytes should come from that tail, subtracts the bytes implied by = padding, and writes just that amount.

But with a malformed ending, the calculation can go like this:

text
Only one character remains: "="
Expected output = (1 / 4) * 3 = 0   // integer division
Subtract 1 for "=" padding: 0 - 1 = -1

And that -1 is the problem.

The decoder uses the output size to build a write mask. Imagine 64 switches, one for each possible output byte. A switch that's on means the byte may be written to memory.

A negative number clearly isn't a sensible output length. But the native instruction building this mask treats that negative count in a way that leaves all 64 switches on.

So instead of writing only the small remainder, the optimized routine may write 64 bytes.

Sources: Datadog — padding and the negative length; Calif — The Tail of Base64.

Diagram: malformed Base64 passes through the Java decoder, HotSpot and the AVX-512 intrinsic before a native memory overwrite

Show me the faulty code.#

Fair enough. Here is the interesting part.

The affected routine is generate_base64_decodeBlock() in OpenJDK's src/hotspot/cpu/x86/stubGenerator_x86_64.cpp.

The snippet below contains selected instructions from the faulty implementation. I skipped intervening code to keep it readable — this isn't a complete function you can compile.

cpp
// Calculate the number of decoded bytes from the remaining input.
__ movl(output_size, length);
__ shrl(output_size, 2);
__ lea(output_size, Address(output_size, output_size, Address::times_2, 0));

// ... padding handling ...
__ decrementq(output_size, 1);

// ... build the write mask and perform the store ...
__ movq(output_mask, -1);
__ bzhiq(output_mask, output_mask, output_size);
__ evmovdqub(Address(dest, dp), k1, tmp, true, Assembler::AVX_512bit);

Let's translate it:

  1. shrl and lea calculate roughly (length / 4) * 3 output bytes.
  2. decrementq accounts for padding. In the malformed-tail case, zero becomes -1.
  3. bzhiq builds the write mask. With that negative number, all 64 bits stay enabled.
  4. evmovdqub performs the masked write. And that's how bytes can land outside the array.

The surprising part is that this is native JVM code. Java normally checks array bounds, but the JVM's own optimized native routine is the thing crossing the boundary.

Here's the OpenJDK source of the affected routine and Akamai's instruction-by-instruction explanation.

What does a 62-byte overflow look like?#

Calif's technical write-up gives a nice concrete example: an affected runtime decoding 64 A characters followed by a single =.

The Java-side length calculation allocates a 50-byte array. The first 64 valid characters decode into 48 bytes, leaving only 2 bytes free inside that array.

The malformed tail then causes a 64-byte write starting at offset 48.

Quick maths: 2 bytes fit. The other 62 bytes are outside the allocated array.

Diagram showing a 50-byte Java array, a 64-byte native store starting at offset 48, and 62 bytes written outside the array

This is an out-of-bounds write. Depending on what's sitting next to the array in heap memory, it could crash the JVM, corrupt another object, or help an attacker build a more complicated exploit.

And here's the really annoying bit: the decoder can still throw IllegalArgumentException afterward, because the Base64 was invalid. But throwing an exception doesn't undo a native memory write that already happened.

A version detail: older OpenJDK 17 builds need a longer malformed input (128 A characters plus =) to reach this code path. The exact trigger isn't identical across every build.

Sources: Calif — the 50-byte allocation and 62-byte overwrite; Datadog — the OpenJDK 17 example and late exception.

And this can become remote code execution?#

Potentially. But memory corruption and reliable RCE aren't the same thing.

An attacker needs to get malformed Base64 into the vulnerable decoder — perhaps through an authentication header, token or other input. Then, to turn that overwrite into code execution, they need to exploit the way objects happen to be arranged in the heap and find something useful to corrupt.

Calif demonstrated RCE in specific tested configurations of products including Keycloak, Jenkins, Jira and Confluence. That took application-specific work. There is no single magic payload for all Java services.

Also, this is Java4Shell, not Spring4Shell and not Log4Shell. The similar names are not helping anyone. :)

Sources: Calif — exploitation and affected products; Group-IB — conditions and limitations.

Does every Java application have the problem?#

No. These conditions need to line up:

  • An affected HotSpot/OpenJDK-based runtime.
  • An x86-64 processor with AVX-512 VBMI and the other required CPU features visible to the JVM.
  • The vulnerable Base64 intrinsic enabled and selected.
  • Attacker-controlled data reaching the affected decoding path.

Native ARM64 JVMs don't execute this x86-specific path. Ordinary OpenJDK 8 and 11 builds don't have this implementation, although vendor-specific performance builds are worth checking separately.

On Linux, you can inspect the relevant CPU flags:

bash
grep -m1 '^flags' /proc/cpuinfo | tr ' ' '\n' | grep -E '^(avx512f|avx512bw|avx512vbmi|bmi2)$'

All four need to be available for the documented attack path. If the application runs in Docker or a VM, what matters is what the running JVM can actually use.

Sources: CERT-EU security advisory; Group-IB — exposure checklist.

What did the actual fix change?#

Interestingly, the upstream fix is tiny. It adds this check before the optimized routine handles the final Base64 fragment:

cpp
// A padded Base64 tail shorter than one complete block is handled by Java.
__ cmpl(length, 4);
__ jcc(Assembler::less, L_bruteForce);

Translation: if fewer than four characters remain, don't send them through this vectorized tail logic. Use the slower scalar path instead.

That prevents the bad calculation from happening on these short, padded fragments.

You can see the exact change in the OpenJDK JDK-8393212 fix commit, with extra context in Akamai's patch analysis.

And how do we mitigate it?#

The actual fix is to update the JDK used by the running application, using your vendor's corrected build.

Java line First fixed OpenJDK release
17 17.0.21.1
21 21.0.13.1
25 25.0.5.1
27 27.0.1.1

If you're using Eclipse Temurin, check the Temurin build number, not just the Java major version. Adoptium lists these first fixed builds:

Eclipse Temurin Fixed build
17 17.0.21.1+2
21 21.0.13.1+2
25 25.0.5.1+2
27 27.0.1.1+4

Temurin 8 and 11 aren't affected by this HotSpot vulnerability. For example, 21.0.13+9 isn't the same build as 21.0.13.1+2. If you're using Docker, check the Java version inside the running container, and don't assume your image updated itself:

bash
docker exec <container-name> java -version

Adoptium also notes that fixed container images are published after the corresponding binaries complete release and testing. Check availability for your platform and image tag before relying on a new version.

Source: Eclipse Adoptium — affected versions, corrected Temurin builds and Docker image rollout (18 Nov 2026).

If patching can't happen immediately, a more targeted temporary workaround is this startup flag:

bash
-XX:-UseBASE64Intrinsics

That tells HotSpot not to use the optimized Base64 intrinsic. It doesn't disable Base64. It just avoids the vulnerable fast path. Some JVM builds may also need -XX:+UnlockDiagnosticVMOptions before that flag.

Another x86-specific workaround is -XX:UseAVX=2, but that disables other AVX-512 optimizations too.

If you use Docker, updating Java on your laptop won't update Java inside your container. You need to update the runtime image, rebuild, redeploy and restart the application.

Sources: CERT-EU — fixed versions and mitigation; Datadog — workaround and verification.

Okay, but how do I test that the JVM actually uses my flag?#

This is the part that started the whole investigation for me.

I wrote a separate, shorter article on checking JVM startup arguments with JConsole, including what to watch out for when the application runs in Docker:

I added a JVM flag in Docker to mitigate the Java4Shell vulnerability. How do I test it?

If you want to check the effective value and have jcmd available, jcmd <PID> VM.flags -all can report UseBASE64Intrinsics = false for the actual process.

Source: Datadog — verify the running JVM.

What I'm taking away from this#

The weirdest part of Java4Shell is that the code in our application can be perfectly normal:

java
Base64.getDecoder().decode(input);

The problem isn't necessarily in what we wrote. It's in an optimization underneath it, in the runtime we're trusting.

Yes, Java protects us from lots of memory mistakes. But the JVM is itself a complicated piece of software, and parts of it run highly optimized native code.

My takeaway is pretty simple: patch the runtime, understand what your mitigation actually changes, and verify the JVM that's running.

Not just the Dockerfile. Not just Jenkins. The process.

Further reading: Original Calif research, OpenJDK patch, Akamai, Datadog and Group-IB.