Under attack right now? hello@incursor.io
BlogPentest

Java4Shell, CVE‑2026‑114938: an out-of-bounds write in HotSpot’s Base64 decoder

On 17 November 2026, Oracle published a security alert and OpenJDK an advisory for CVE-2026-114938, nicknamed Java4Shell and scored 9.2 under CVSS 4.0. The flaw is in the AVX-512 assembly routine that HotSpot substitutes for the standard library’s Base64 decoder once C2 has compiled it. On an x86-64 processor with AVX-512 VBMI, a malformed Base64 input makes the decoder write up to 62 bytes past the end of its output array. The fix is an update followed by a restart. Finding every affected JVM, including the ones bundled in products and container images, takes longer.

Gerard Capdevila Nov 2026 · 14 min read · Java
KEY TAKEAWAYS
Out-of-bounds write in the AVX-512 stub for Base64.Decoder (stubGenerator_x86_64.cpp), reached when C2 compiles decodeBlock(). CVSS 4.0: 9.2.
Conditions: an x86-64 CPU with avx512f, avx512bw, avx512vbmi and bmi2, a decoder hot enough to be compiled, and attacker-controlled input passed to Base64.getDecoder() or getUrlDecoder(). ARM64 is not affected.
Oracle’s fixed builds are 17.0.21.1+4, 21.0.13.1+4, 25.0.5.1+4 and 27.0.1.1+4. Java 17 is affected from 17.0.6.
Workaround until you can update: -XX:-UseBASE64Intrinsics, checked with jcmd on every process.

1. Timeline and sources

Quang Luong at Calif found the bug with help from an AI model. According to Calif, finding it took about an hour and the first exploit two more hours, for less than 200 dollars in tokens. Jenish Rakholiya then improved the exploit. Calif, which also published on PHP2Shell, reported the flaw to Oracle. The fix shipped on 17 November at 1 pm Pacific time, together with an OpenJDK advisory. This post draws on Calif’s write-up and on the analysis by Sebastian Obregoso and Nick Frichette at Datadog Security Labs, both dated 17 November. The source excerpts below come from jdk17u, the tree Datadog analysed. Calif is holding back its application-specific exploit chains for now, and as of 19 November neither source reports exploitation in the wild.

2. The Java side: decode() and decodeBlock()

Base64.Decoder.decode(byte[]) first sizes the output array with decodedOutLength(), then calls decode0(). On the fast path, decode0() hands whole blocks to decodeBlock(), a method annotated @IntrinsicCandidate. Its Javadoc states that no length check is possible on dst inside that method, so dst is assumed to be large enough. The Java implementation of decodeBlock() only processes complete groups of four characters. Once C2 compiles the method, HotSpot replaces it with the hand-written stub from stubGenerator_x86_64.cpp, and that stub handles the final fragment itself.

// java/util/Base64.java, Base64.Decoder (jdk17u)
public byte[] decode(byte[] src) {
    byte[] dst = new byte[decodedOutLength(src, 0, src.length)];   // size computed from the input
    int ret = decode0(src, 0, src.length, dst);
    if (ret != dst.length) {
        dst = Arrays.copyOf(dst, ret);
    }
    return dst;
}

private int decode0(byte[] src, int sp, int sl, byte[] dst) {
    ...
    while (sp < sl) {
        if (shiftto == 18 && sp < sl - 4) {       // fast path
            int dl = decodeBlock(src, sp, sl, dst, dp, isURL, isMIME);   // replaced by the AVX-512 stub once C2 compiles it
            ...

@IntrinsicCandidate                                   // HotSpot intrinsic
private int decodeBlock(byte[] src, int sp, int sl, byte[] dst, int dp,
                        boolean isURL, boolean isMIME) { ... }

3. Sizing the output: decodedOutLength()

decodedOutLength() counts trailing = signs as padding and subtracts them from the output size. It does not reject a lone = at the end of an otherwise complete set of groups. For Datadog’s 129-character input, the method returns 98, and decode() allocates a 98-byte array.

private int decodedOutLength(byte[] src, int sp, int sl) {
    ...
    } else {
        if (src[sl - 1] == '=') {
            paddings++;
            if (src[sl - 2] == '=')
                paddings++;
        }
    }
    if (paddings == 0 && (len & 0x3) !=  0)
        paddings = 4 - (len & 0x3);
    ...
    return 3 * (int) ((len + 3L) / 4) - paddings;
}

// Datadog’s example: 129 characters, the last one is a lone '='
//   len      = 129
//   paddings = 1
//   3 * ((129 + 3) / 4) - 1 = 3 * 33 - 1 = 98   (bytes allocated for dst)

4. The AVX-512 stub: 64 characters per iteration

On a processor with AVX-512 VBMI, the stub decodes 64 Base64 characters into 48 bytes per loop iteration and writes them with a masked vector store. With 129 characters, two iterations consume 128 characters and write 96 bytes. The stub then jumps to L_finalBit with a single character left.

// hotspot/cpu/x86/stubGenerator_x86_64.cpp, generate_base64_decodeBlock()
// Main loop: 64 Base64 characters in, 48 bytes out per iteration
__ evmovdqub(Address(dest, dp), k2, merged0, true, Assembler::AVX_512bit);

__ subl(length, 64);          // 128 characters -> two iterations, 96 bytes written
__ addptr(source, 64);
__ addptr(dest, 48);

__ cmpl(length, 64);
__ jcc(Assembler::greaterEqual, L_process64Loop);

__ cmpl(length, 0);
__ jcc(Assembler::lessEqual, L_exit);

__ BIND(L_finalBit);
// Now have 1 to 63 bytes left to decode      (here: 1 character left, the '=')

5. The final fragment: a counter that goes negative

L_finalBit computes the output size of the remaining fragment as (len / 4) * 3 with a shift and an lea. For one character the result is 0. The stub then checks whether the last character is = and jumps to L_padding, which decrements output_size by one for each padding sign. Nothing checks that output_size stays non-negative, so it becomes -1, or -2 for other tail forms.

__ BIND(L_finalBit);
__ movq(rax, -1);
__ bzhiq(rax, rax, length);    // Input mask in rax

__ movl(output_size, length);
__ shrl(output_size, 2);   // Find (len / 4) * 3 (output length)
__ lea(output_size, Address(output_size, output_size, Address::times_2, 0));
// output_size in r13          // (1 / 4) * 3 = 0

// Strip pad characters, if any, and adjust length and mask
__ cmpb(Address(source, length, Address::times_1, -1), '=');
__ jcc(Assembler::equal, L_padding);

...

__ BIND(L_padding);
__ decrementq(output_size, 1);   // 0 - 1 = -1, never checked
__ shrq(rax, 1);

__ cmpb(Address(source, length, Address::times_1, -2), '=');
__ jcc(Assembler::notEqual, L_donePadding);

__ decrementq(output_size, 1);   // -2 for the '==' tail forms
__ shrq(rax, 1);
__ jmp(L_donePadding);

6. From the BZHI mask to a 64-byte write

The output mask is built with BZHI, which clears the bits of a register above a given index and only reads the low byte of that index. -1 becomes 255 and -2 becomes 254. Both exceed the 64-bit mask width, so BZHI clears nothing and the mask stays all ones. The masked store then writes 64 bytes at offset 96 of a 98-byte array, 62 bytes past its end. The attacker does not choose those bytes. Before decoding, the stub fills unused input lanes with 0x61 (the character a), so the overflow mostly contains the pattern 69 a6 9a. Calif describes the result as a near-constant-value overwrite of adjacent heap objects.

__ BIND(L_donePadding);

// Output size is (64 - output_size), output mask is (all 1s >> output_size).
__ kmovql(input_mask, rax);
__ movq(output_mask, -1);
__ bzhiq(output_mask, output_mask, output_size);   // BZHI only reads the low byte of output_size

// Load initial input with all valid base64 characters.
__ movl(rax, 0x61616161);                            // unused lanes are filled with 'a'
__ evpbroadcastd(input_initial_valid_b64, rax, Assembler::AVX_512bit);
...
__ kmovql(k1, output_mask);
__ evmovdqub(Address(dest, dp), k1, tmp, true, Assembler::AVX_512bit);   // masked 64-byte store

__ addptr(dest, output_size);

// Result for the 129-character input
//   output_size        = -1  ->  BZHI index = 0xFF = 255  (>= 64)
//   output_mask        = 0xFFFFFFFFFFFFFFFF  (64 bytes enabled)
//   dst.length         = 98, store offset = 96
//   bytes written: 96..159  ->  62 bytes past the end of dst

7. The exception comes after the write

When the stub returns, decode0() continues with the remaining character, sees a padding byte where no group is in progress, and throws IllegalArgumentException. The heap has already been modified. An application that catches the exception, which is common when parsing untrusted tokens, keeps running with a corrupted neighbouring object.

// decode0(), after the stub has returned
if ((b = base64[b]) < 0) {
    if (b == -2) {         // padding byte '='
        // =     shiftto==18 unnecessary padding
        ...
        if (shiftto == 6 && (sp == sl || src[sp++] != '=') ||
            shiftto == 18) {
            throw new IllegalArgumentException(          // thrown after the overflow, too late
                "Input byte array has wrong 4-byte ending unit");
        }

8. Exploitation conditions

The processor has to be an x86-64 part that exposes avx512f, avx512bw, avx512vbmi and bmi2; native ARM64 JVMs never run this stub. The JVM has to be an affected version, the decoder has to be compiled by C2 (which happens quickly on a service that decodes Base64 all day), and attacker-controlled data has to reach Base64.getDecoder() or Base64.getUrlDecoder(). Calif also lists some Oracle Java SE 8 “perf” builds. Distributions built from OpenJDK share the code: Amazon Corretto, Eclipse Temurin, Microsoft Build of OpenJDK, Azul Zulu, BellSoft Liberica, SapMachine, Red Hat OpenJDK and GraalVM. In the 17.0.6 build Datadog tested, Base64.getMimeDecoder() does not take the AVX-512 path, and Datadog adds that libraries implementing their own Base64 decoding may behave differently.

CPU (x86-64)    avx512f  avx512bw  avx512vbmi  bmi2
JIT             C2 has compiled Base64.Decoder.decodeBlock()
API             Base64.getDecoder() / Base64.getUrlDecoder()

JAVA LINE   AFFECTED                         FIRST FIXED (ORACLE)
17          17.0.6  ->  < 17.0.21.1          17.0.21.1+4
21          all     ->  < 21.0.13.1          21.0.13.1+4
25          all     ->  < 25.0.5.1           25.0.5.1+4
27          all     ->  < 27.0.1.1           27.0.1.1+4

9. Observed impact

Datadog considers denial of service the most accessible impact. In its standalone test, the overflow corrupts the header of a neighbouring array and the JVM crashes later, during garbage collection. Calif also mentions heap memory disclosure, which it compares to Heartbleed. Code execution requires placing an exploitable object right after the output buffer. That heap layout depends on the application, the JVM and network timing, and Calif says each target needs a bespoke profile. Calif still reports unauthenticated code execution on Keycloak, Atlassian Jira and Confluence, JFrog Artifactory, Jenkins and PingFederate, and authenticated code execution on Apache Kafka, Apache Solr, Elasticsearch, Gerrit and Spinnaker, as well as on Struts and Spring Boot sample applications. Clients are exposed too. A Java client that opens a TLS connection to a malicious server can be compromised, and samczsun shared an exploit of that kind with Calif.

10. Checking a host and a process

Start with the processor flags, then look at the JVM that is actually running rather than the java on the PATH. The inventory has to cover runtimes bundled in applications, appliances and container images: an image rebuilt from an old base keeps the old JDK even when the host is up to date.

# 1. Host: does the CPU expose VBMI? (no output = not affected)
grep -om1 -E 'avx512[_]?vbmi' /proc/cpuinfo

# 2. Running JVMs and their exact version
jcmd -l
jcmd <PID> VM.version

# 3. Is a workaround active on this process?
jcmd <PID> VM.flags -all | grep -E 'UseBASE64Intrinsics|UseAVX '

# 4. JDK inside a container image
docker run --rm --entrypoint java <image> -version

11. Fixes and workarounds

Oracle’s fixed builds are 17.0.21.1+4, 21.0.13.1+4, 25.0.5.1+4 and 27.0.1.1+4, and OpenJDK distributors ship their own. Updating the package only protects a process after it restarts, and container images have to be rebuilt and redeployed. Until then, -XX:-UseBASE64Intrinsics turns off only the Base64 intrinsic and leaves the rest of the JVM unchanged. -XX:UseAVX=2 caps the JVM at AVX2 and also removes the vulnerable path, but it affects other optimisations and needs load testing. Upstream filtering does not replace the fix: Calif notes that nginx request buffering does not mitigate the flaw, and a WAF cannot see Base64 that the application extracts from a token before decoding it.

# Narrow workaround: disable only the Base64 intrinsic
java -XX:-UseBASE64Intrinsics -jar app.jar

# Same flag for every JVM started in this environment
export JAVA_TOOL_OPTIONS="-XX:-UseBASE64Intrinsics"

# Broader workaround, x86-64 only (an ARM64 JVM refuses to start with it)
java -XX:UseAVX=2 -jar app.jar

# Check it on the running process
jcmd <PID> VM.flags -all | grep UseBASE64Intrinsics
#   bool UseBASE64Intrinsics = false

12. Our take

The priority targets are exposed Java services that decode Base64 before authentication: identity providers such as Keycloak and PingFederate, and Jenkins, Jira, Confluence and Artifactory servers. I would also put Java clients that connect to external servers on the list, because they are rarely inventoried. Calif puts the discovery and first exploit at a few hours and under 200 dollars. At that cost, tailoring an exploit to one target pays off, even when the flaw needs a heap profile per application.

DO THIS TODAY
→List Internet-facing Java services on x86-64, starting with Keycloak, PingFederate, Jenkins, Jira, Confluence and Artifactory.
→Check the AVX-512 flags in /proc/cpuinfo and the version of each process with jcmd <PID> VM.version.
→Move to 17.0.21.1, 21.0.13.1, 25.0.5.1 or 27.0.1.1 depending on the branch, then restart every process.
→Rebuild and redeploy container images instead of updating running containers in place.
→If the update has to wait, add -XX:-UseBASE64Intrinsics and confirm UseBASE64Intrinsics = false with jcmd <PID> VM.flags -all.
→Include Java clients that connect to the outside: agents, batch jobs and internal tools.

FAQ

Our servers run on ARM64. Are we affected?

Not on native ARM64 JVMs, for example on AWS Graviton. The vulnerable stub only exists on x86-64 and only runs when the processor exposes AVX-512 VBMI.

Our code never calls Base64. Are we exposed?

Probably. Frameworks and libraries decode Base64 for tokens, authentication headers and attachments, and the products Calif tested are examples of that. The update is still needed.

Is the -XX:-UseBASE64Intrinsics workaround enough?

It closes the vulnerable path for as long as it is active on each JVM, which jcmd can confirm. It does not replace the fixed build, which should be deployed as soon as possible.

How does Java4Shell compare with Log4Shell?

Log4Shell worked with a single string on almost every vulnerable installation. Java4Shell depends on the processor, and code execution needs a heap profile specific to each application. Crashing the JVM needs none of that work, which is enough to treat the flaw as a critical priority.

What should we look for in our logs?

There is no public signature yet. Useful signs are unexplained JVM crashes or restarts since 17 November, new hs_err_pid files, and requests carrying long Base64 strings that end with a lone = sign.

Related services Audit & Pentest Incursor Reaper

Want to know if your Java services are exposed?

Test us. An expert hacker replies within one business day.
Incursor
© 2026 Incursor Security · Paris · Barcelona · Amsterdam · EU based
{{ rIncidentQ }} hello@incursor.io
Incursor {{ menuLabel }}
{{ navServices }} {{ navEngagements }} {{ navMethod }} {{ navTeam }} {{ navBlog }}
{{ navContact }}
{{ navBlog }}{{ arCat }}

{{ arT }}

{{ arLede }}

{{ arAuthor }} {{ arMeta }}
{{ arTldrT }}
{{ b }}

{{ sec.n }}. {{ sec.h }}

{{ sec.p }}

{{ sec.code }}
{{ li.t }} {{ li.t }}
{{ heatLowL }}
{{ heatMediumL }}
{{ heatHighL }}
{{ heatCriticalL }}
{{ arFlagsT }}
{{ arFlagMark }}{{ f }}

{{ arFaqT }}

{{ q.q }}

{{ q.a }}

{{ arSvcT }} {{ sv.t }}

{{ arCta }}

{{ rHmEndBtn }} {{ rHmEndNote }}
Incursor
© 2026 Incursor Security · {{ cities }}