KernelBreakpoint
All posts
Offensive SecurityCVEJavaRCE

java4shell: How one malformed Base64 string smashes the JVM heap

CVE-2026-114938 down to the mask underflow: how 64 'A' characters and a single '=' turn OpenJDK's AVX-512 Base64 intrinsic into a heap overflow, and the groom from there to pre-auth RCE.

KernelBreakpoint·November 18, 2026·6 min read

java4shell is CVE-2026-114938, a CVSS v4.0 9.2 remote code execution bug in OpenJDK disclosed in November 2026. There is no injection, no deserialization, no gadget chain in library code. The bug is in the JVM's own hand-written SIMD assembly for decoding Base64, which is a reminder that performance intrinsics are unsafe code wearing a safe-language badge.

The TL;DR

  • An out-of-bounds heap write in OpenJDK's AVX-512 Base64 decode intrinsic.
  • Triggered by a malformed Base64 string: 64 A characters followed by a single =.
  • Reachable pre-auth wherever a service Base64-decodes untrusted input, which is almost everywhere: auth headers, JWTs, cookies, uploads.
  • Only affects x86-64 CPUs with AVX-512 VBMI. ARM64 is unaffected, and so are Java 8 and 11.
  • Fixed in OpenJDK 17.0.21.1, 21.0.13.1, 25.0.5.1 and 27.0.1.1.
!

A reliable crash is halfway to a reliable exploit. Treat a wave of JVM segfaults in Base64 or hotspot frames as a security event.

Root cause: the AVX-512 padding bug

Since JDK 17.0.6, java.util.Base64 uses an AVX-512 VBMI intrinsic: a block of hand-written SIMD assembly that decodes 64 input characters at a time far faster than the scalar path. The intrinsic computes how many output bytes to write, then converts that count into a write mask using the BZHI instruction.

The mask math is wrong when the input ends in an unexpected number of padding (=) characters. The stub computes the output length as (len / 4) * 3, then subtracts one per padding character. For a tail where that calculation should produce zero, subtracting a padding character yields -1, which in an 8-bit register wraps to 255. That cleared mask tells the CPU to write a full 64 bytes where it should have written zero.

The mask underflow turns a zero-byte write into a 64-byte heap smash.

Why 64 A's and a single '='

The canonical trigger is 64 A characters followed by a single = (on JDK 17, researchers also report 128 As). With that input the stub writes 64 bytes starting at byte offset 48 of the output region. Only 2 of those bytes land inside the destination array. The other 62 spill into whatever sits next on the heap.

The vulnerable call is almost offensively boring:

This is the whole sink
import java.util.Base64;
 
// externalInput is attacker-controlled, for example an auth header value
byte[] out = Base64.getDecoder().decode(externalInput);

No flags, no unusual API, no reflection. Any code path that decodes attacker-controlled Base64 on an affected JVM and CPU is a candidate.

How attacker bytes reach the decoder

Base64 is everywhere untrusted data enters a Java service: HTTP Basic auth headers, JWT segments, cookies, multipart uploads, and binary fields in network protocols. Because the decode often happens during authentication or request parsing, the bug is reachable before login. That is why the proven-vulnerable list reads like a corporate network diagram: Jira, Confluence, Jenkins, Keycloak, Artifactory, Tomcat, Elasticsearch and Spring Boot services among others.

A Basic-auth probe is the simplest shape to reason about. The server Base64-decodes the credential before it ever checks it, reaching the vulnerable intrinsic on the parse path:

Untrusted Base64 in an auth header
GET /rest/api/latest/myself HTTP/1.1
Host: target.example
Authorization: Basic QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUE9

From overflow to code execution

A 62-byte linear overflow is not instant RCE, it is a primitive. Java arrays store their length header immediately before their data, so the overflow can clobber the length field of an adjacent array. From there the recipe is textbook:

  1. Groom the heap so a writer array sits directly before a reader array.
  2. Overflow the writer to enlarge the reader array's length field.
  3. The oversized reader array is now an arbitrary read, used to leak heap secrets such as tokens and keys.
  4. Turn the same corruption into an arbitrary write, then write shellcode into the JIT code cache and get RCE.

Reliability is the hard part. Memory layout varies across deployments, so a single universal exploit is difficult. Researchers built a working proof-of-concept in about two hours but noted that generalizing to an arbitrary target is non-trivial. As of mid-November 2026 there was no public RCE exploit, which is exactly the window defenders should be patching in.

Attack chain

Attack chain
  1. Send a malformed Base64 string

    64 'A' characters then a single '=' in an auth header, JWT, or cookie.

  2. Reach the AVX-512 Base64 intrinsic

    Base64.getDecoder().decode() routes to the vulnerable SIMD stub, pre-auth.

  3. The write mask underflows

    (len / 4) * 3 minus the padding wraps to 255 and clears the write mask.

  4. Write 64 bytes at offset 48

    Only 2 bytes are in-bounds; 62 overflow into the adjacent heap object.

  5. Clobber the array length header

    Groom the heap to enlarge a reader array into arbitrary read and write.

  6. Write the JIT code cache, get RCE

    Leak secrets, then redirect execution into attacker-controlled code.

Am I affected?

Vulnerable: OpenJDK 17.0.6 and later across distributions (Temurin, Corretto, Zulu, Microsoft Build and others), and only on x86-64 CPUs with AVX-512 VBMI. That means recent Intel Xeon (Ice Lake and later) and AMD Zen 4 and later. ARM64 is not affected at all, and Java 8 and 11 predate the intrinsic. Check the CPU feature directly:

Does this host have the vulnerable SIMD path?
grep -m1 '^flags' /proc/cpuinfo | tr ' ' '\n' \
  | grep -E '^(avx512f|avx512bw|avx512vbmi|bmi2)$'

If avx512vbmi is absent, that host cannot reach the vulnerable intrinsic even on an affected JDK.

Detection and threat hunting

Hunt the input and the crash:

  • Base64 inputs whose length is a multiple of 64 and that end in long runs of A followed by padding, arriving in auth headers, JWTs or cookies.
  • JVM crashes with SIGSEGV in Base64 or hotspot intrinsic frames. The crash is the cheap-to-reach half of this bug, so a wave of JVM segfaults is a strong early indicator.

Mitigation and patching

Patch to OpenJDK 17.0.21.1, 21.0.13.1, 25.0.5.1 or 27.0.1.1. If you cannot patch now, disable the vulnerable code path. These flags apply only to x86-64, since ARM64 is unaffected and should not use them:

JVM flags that sidestep the intrinsic
# Preferred: disable just the Base64 intrinsic.
java -XX:-UseBASE64Intrinsics -jar app.jar
 
# Alternative: drop below AVX-512 entirely.
java -XX:UseAVX=2 -jar app.jar

Key takeaways

  • Hand-written SIMD is a growing attack surface. The safety of the language stops at the intrinsic boundary.
  • Pre-auth reachability is what makes this urgent. Base64 decoding sits in front of authentication in most services.
  • Hardware shapes exposure. Your risk is a JDK-plus-CPU combination, not just a version string.
  • Patch in the quiet window. No public RCE yet is the best possible time to roll the upgrade.

See the companion teardown of the PHP side in php2shell.

References