Java4Shell: How a malformed Base64 string breaks the JVM on AVX-512
View all articlesQuincy Castro
CISO
Chainguard
Quincy Castro CISO
Today, Oracle shipped its November 2026 Critical Patch Update. Eleven of the fixes are for Java SE. One of them is CVE-2026-114938, now called Java4Shell. It’s reported at about 9.2 severity on CVSS 4.0. It affects Java 17, 21, 25, and 27.
A malformed Base64 string makes the Java decoder write past the end of an array on a common class of server CPU. The write corrupts the Java heap. From there, an attacker can crash the server, read other users' secrets from memory, or run code.
We found this bug late last week while scanning an open source project with Chainguard Harness and reported it to Oracle. The fix is in today’s Java security releases, including OpenJDK 17.0.21.1, 21.0.13.1, 25.0.5.1, and 27.0.1.1, and Amazon Corretto 17.0.21.1.2, 21.0.13.1.2, 25.0.5.1.2, and 27.0.1.1.4.
Simultaneous discovery is becoming the new norm
This bug was found three different times in the last few weeks.
A fix for it sat in public on GitHub for two months. Someone proposed it as pull request openjdk/jdk#32781 on September 9. The PR was auto-closed without merging, so the bug stayed open in shipped builds.
Then, a researcher at calif found it on October 30.
We then found it on November 13.
As access to frontier AI models expands, it makes it easier for anyone to discover new, critical vulnerabilities at scale. However, discovery is not even half of the battle as issuing the fixes across all impacted software requires numerous vendors patching rapidly and organizations upgrading just as fast.
This vulnerability is especially challenging given how many JDK builds are impacted. One CVE maps to many Java builds. There are several OpenJDK streams, many downstream variants, and many vendor builds. Each one needs its own patched release. And then each release needs to be adopted.
How we found it
Chainguard Harness was scanning an open source Java server cluster, looking for server vulnerabilities, when this JDK issue appeared.
Chainguard Harness wrote fuzzing harnesses for the server's credential parsers. Each harness fed malformed data into the code that reads an HTTP Authorization header. One harness run died after about three minutes with a JVM crash (SIGSEGV). The crash was not in the server's code. It was in a JDK routine named base64_decodeBlock, the hand-written machine code that decodes Base64.
Our sub-agents then isolated the crash with the plain JDK. It found that a specific shape of malformed Base64 made the decoder write past the end of its output array. It confirmed that the server reached this code before it checked any credential. We characterized the bug and reported it to Oracle.
The breakdown below explains how the vulnerability works.
Background
Java promises that code cannot read or write outside an object. Every array access gets a bounds check.
The hottest routines are different. For these, the JVM replaces the Java code with hand-written machine code called an intrinsic, or a stub. The JVM's own engineers write these stubs in assembly-tuned C++, one version per CPU type. The stubs are much faster. They also sit outside Java's safety net. A stub must get its own bounds right because if it doesn’t, there’s nothing that catches the mistake.
Base64 decoding is one of these routines. It runs everywhere: HTTP auth headers, tokens, cookies, certificates, JSON fields.
What is AVX-512 VBMI?
A normal CPU instruction works on one value at a time. A single instruction, multiple data (SIMD) instruction works on a vector of values at once. On x86, the SIMD register sizes are 128-bit (SSE), 256-bit (AVX2), and 512-bit (AVX-512). A 512-bit register has 64 bytes.
AVX-512 VBMI ("vector byte manipulation") adds instructions that move bytes around inside a register. Base64 decoding needs exactly this: map 64 input characters to 6-bit values, then pack them into 48 output bytes. With VBMI, the decoder handles 64 characters per step instead of one. This is several times faster, so the JVM turns this path on by default on CPUs that have VBMI.
VBMI is common on current servers such as Intel Ice Lake, Sapphire Rapids, and later, and AMD Zen 4 and later. Many cloud instances have it.
Vector code works in fixed-size chunks, so it must handle the tail: the last few bytes that do not fill a chunk. AVX-512 has masked stores for the tail. A masked store writes only the bytes that a bit mask turns on. The bug lives in the tail path.
The bug
Base64.getDecoder().decode(String) works in three steps:
Size the output — Java computes the exact decoded length and allocates a
byte[]of exactly that size.Decode it — The stub decodes the input into that array.
Validate it — If the input was invalid, Java throws
IllegalArgumentException.
Valid Base64 always has a length that is a multiple of 4. The issue arises when you feed the decoder invalid input, such as 64·k + 1, 2, or 3, and end it with =. For example, 64 Q characters followed by =.
Here is what happens:
Java sizes the output array for that odd length. It is a few bytes too small to be a real Base64 length, but Java allocates it anyway.
The stub decodes the full 64-character chunks with no problem.
A final block of 1 to 3 characters is left, ending in =. The stub's padding path computes how many output bytes this block produces. The math goes negative. A negative count turns into a bad mask that enables every byte, allowing the stub to run a full 64-byte store at the end of the output.
The array, however, is not that long. Up to 62 bytes land past the end of the array.
Only after the store does Java check the input, see that it is invalid, and throw.
So the exception comes after the out-of-bounds write has already happened.
The overflow bytes are always the same pattern (9a 69 a6 …), taken from the stub's lookup table. The attacker cannot choose these bytes, but it can choose when the overflow happens, how often, and the size of the output array. The size decides where the allocator puts the array, which decides what sits next to it in memory.
Well-formed Base64 never triggers the bug. It needs an invalid length and padding.
Why a fixed 62-byte pattern is still dangerous
The decoded output is an array. Java stores objects one after another in memory. It leaves no space between them, meaning another object sits right after the output array. The overflow writes extra bytes past the end of the output array, so those bytes hit the start of the next object.
Each object starts with a header. An array’s header holds its length. The JVM reads that length on every bounds check, and then the overflow overwrites that header. The result depends on which object comes next.
The two results are:
The next object is an ordinary object. Its header gets corrupted. The next time the garbage collector or other code touches it, the JVM crashes. An attacker reaches this with no account, through any server that Base64-decodes a header before it checks credentials. This is a reliable remote crash on every node.
The next object is an array that the attacker controls. Its length field becomes about 1.7 billion. Code that indexes that array now reads and writes far past its real end. This is the start of a full exploit, but only if the attacker can place a chosen array there.
Controlling the next object
To place a chosen array as the next object, the attacker must control the order of allocations. An embedded scripting language offers this. Many Java servers let a low-privilege user run "safe" scripts from an allowlist, and those scripts can allocate arrays and call Base64 decode.
The JVM's default collector, G1, splits the heap into equal regions. A large object gets whole regions to itself, placed in order. This makes heap layout predictable. At a high level, the attacker does this:
Pick a decode size that fills exactly one region.
Allocate several large arrays so they sit in a row of regions.
Free one array to leave a hole.
Decode into the hole, so the overflow lands on the header of the next array.
The chosen array now has a huge length. From there, the script builds a stable read-and-write primitive over the whole heap, and it repairs the corrupted header so the garbage collector does not crash. We are not publishing the step-by-step primitive. The point is that a fixed-pattern, 62-byte overflow becomes full control of heap memory.
From heap read/write to owning the server
Once a script can read and write any heap address, the allowlist stops meaning anything. In our Chainguard Harness run, a low-privilege script user did all of the following:
Read other users' secrets from memory, including basic-auth passwords, API keys, service tokens, and response data the user could not otherwise see.
Read a node's TLS private key from memory and used it to join a rogue node to the cluster.
Rewrote its own cached roles in memory to become a superuser.
Escaped the script allowlist. It patched one allowed constructor's recorded parameter type in memory, so an allowlist-clean script compiled into a call that opens a file for writing. A file was created as the server's OS user.
Process spawning was blocked at the OS level in our run, so this stopped at the arbitrary file write inside the JVM. A companion web application reached full code execution by chaining this primitive with another bug.
Who is exposed
Two groups are exposed:
Any Java service on AVX-512 VBMI hardware that Base64-decodes attacker-supplied input with
java.util.Base64before it validates length and padding. This coversAuthorizationheaders, tokens, cookies, JSON fields, and certificates. The floor is a remote heap-corruption crash. The ceiling depends on what the application allocates next to the output array.Products that embed a sandboxed or allowlisted scripting language that exposes Base64 decoding. This covers search and analytics engines, rule engines, template and workflow languages, and plugin hosts. For these, the bug reaches arbitrary heap read/write and an allowlist escape.
Fixing and mitigating
The upstream fix is a short early return in the stub when fewer than 4 characters remain. Update to a release that includes the fix: OpenJDK jdk-17.0.21.1-ga, jdk-21.0.13.1-ga, jdk-25.0.5.1-ga, or jdk-27.0.1.1-ga, or Amazon Corretto 17.0.21.1.2, 21.0.13.1.2, 25.0.5.1.2, or 27.0.1.1.4. Java 8 and 11 aren’t affected by Java4Shell, but today’s releases (jdk8u514-ga, jdk-11.0.33.1-ga) fix other vulnerabilities in them. Chainguard has published fixed packages (openjdk-8 8.514, openjdk-11 11.0.33.1, openjdk-17 17.0.21.1, openjdk-21 21.0.13.1, openjdk-25 25.0.5.1, and openjdk-27 27.0.1.1) and is rebuilding affected images now. Patched builds are available on our free Chainguard Starter plan.
If you cannot update at once, use one of these:
JVM flag
-XX:-UseBASE64Intrinsics. This uses the bounds-checked Java decoder, at some throughput cost.JVM flag
-XX:UseAVX=2. This avoids the vulnerable stub path.Application check: reject Base64 input whose length is not a multiple of 4, after you strip whitespace, before you call
decode. The trigger needs a malformed length.
Whether or not you update, if your product runs untrusted JVM code, you should isolate that code at the process or OS level. An allowlist is effective only as long as Java's memory safety is intact.
Share this article
Related articles
securityPHP's November security release: What it is and what to update
securityWhat CISOs and CTOs need to do to minimize agentic risk in 2027
securityInnovating safely with AI: Security and engineering leaders on life after the patch era
securityReact2STEAL: What it is and what to check
securityMicrosoft agent-framework compromised on PyPI: 1.26.1 and 1.26.2 ship a credential stealer that runs on every Python start (November 2026)
securityPrevention Under Pressure: Why most AI governance is "detection wearing prevention clothes"