Sixty-four A characters and one equals sign: how OpenJDK's Base64 fast path wrote 62 bytes past the buffer

Feed this single line to the OpenJDK Base64 decoder and, on certain x86-64 servers, it writes 62 bytes past the end of the heap allocation before it ever throws IllegalArgumentException:

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=

Sixty-four A characters and one equals sign. The buffer is allocated at 50 bytes. The write starts at offset 48 and runs through offset 111. The exception is still thrown, the stack trace still looks clean, and the memory next door is no longer what it was. This is Java4Shell, CVE-2026-114938, CVSS 4.0 score 9.2.

The disclosure comes from the security team at Calif (the lcamtuf lineage) and went public on 2026-11-18. Greg Brockman amplified it on X the same morning, crediting GPT-6 Cyber for finding it. It hit 983 points at third place on Hacker News. Chinese outlets picked it up within hours.

1. Whether you are exposed depends on two conditions, not one

What is affected is the x86-64 Base64 intrinsic in OpenJDK HotSpot: the path where C2 JIT compiles java.util.Base64 decoding into AVX-512 VBMI accelerated code. So the triage needs both halves:

  • Version: OpenJDK 17.0.6 and later. Oracle lists 8u511b33-perf, 17.0.21.0.3, 21.0.13.0.3, 25.0.5.0.3 and 27.0.1.0.3 as affected in the same patch batch. Corretto, Temurin, Zulu, Liberica, SapMachine, Microsoft Build and GraalVM for JDK all inherit it.
  • Hardware: x86-64 with AVX-512 VBMI, meaning Intel Xeon from Ice Lake onward and AMD EPYC or Ryzen from Zen 4 onward. ARM64 has none of that assembly and is unaffected.

I happen to have a JDK sitting exactly on the version boundary here: 17.0.6. The standalone trigger Calif published looks like this, and every write stays inside a real 4096-byte array, so simply running it breaks nothing:

import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Base64;

public final class Base64Trigger {
    private static volatile int sink;

    public static void main(String[] args) {
        Base64.Decoder decoder = Base64.getDecoder();
        byte[] valid = "A".repeat(64).getBytes(StandardCharsets.US_ASCII);
        byte[] malformed = ("A".repeat(64) + "=").getBytes(StandardCharsets.US_ASCII);
        byte[] target = new byte[4096];

        for (int i = 0; i < 200_000; i++) {
            sink += decoder.decode(valid, target);
        }

        Arrays.fill(target, (byte) 0x5a);
        boolean rejected = false;
        try {
            decoder.decode(malformed, target);
        } catch (IllegalArgumentException expected) {
            rejected = true;
        }

        int changed = 0;
        int first = -1;
        int last = -1;
        for (int i = 50; i < target.length; i++) {
            if (target[i] != (byte) 0x5a) {
                changed++;
                if (first < 0) first = i;
                last = i;
            }
        }

        System.out.println("runtime=" + System.getProperty("java.runtime.version"));
        System.out.println("vm=" + System.getProperty("java.vm.name"));
        System.out.printf("rejected=%s changed=%d first=%d last=%d%n",
            rejected, changed, first, last);

        if (!rejected || changed != 62 || first != 50 || last != 111) {
            System.err.println("NOT REPRODUCED");
            System.exit(1);
        }
        System.out.println("REPRODUCED");
    }
}

Compile and run:

$ javac Base64Trigger.java && java Base64Trigger
runtime=17.0.6+9-LTS-190
vm=Java HotSpot(TM) 64-Bit Server VM
rejected=true changed=0 first=-1 last=-1
NOT REPRODUCED

The version is squarely inside the affected range and nothing happens. This machine is a Core Ultra 5 338H, an Arrow Lake part with no AVX-512, so the intrinsic takes a different branch. This is exactly where triage goes wrong: version alone flags safe machines as vulnerable and lets vulnerable machines believe they are fine. Inventory checks need both conditions or the answer is wrong in both directions.

A useful side check is to ask the JIT what it actually chose:

$ java -XX:-UseBASE64Intrinsics -XX:+PrintFlagsFinal -version 2>/dev/null | grep -E "Base64Intrinsics|UseAVX"
     intx UseAVX                                   = 2                                    {ARCH product} {default}
     bool UseBASE64Intrinsics                      = false                                {product} {command line}

UseAVX defaults to 2 (AVX2 here), which confirms this box never entered the AVX-512 path. The second line doubles as proof that the mitigation flag actually took effect: the {command line} tag means the value came from the command line rather than the default. During incident work I always read that line. Config files get edited, environment variables override them, wrapper scripts drop arguments, and the effective value is the only thing worth trusting.

2. The root cause is an integer underflow, not a missing bounds check

The intrinsic iterates input in 256-byte chunks and handles the remainder in 64-byte blocks. The tail block is written with evmovdqub (VMOVDQU8), which takes a 64-bit mask k1 deciding which bytes actually reach memory. The mask is computed from lengths:

input_mask  := bzhiq(-1, input_length)
output_len  := (input_length / 4) * 3

if input[input_length - 1] == '=':
    output_len -= 1
    input_mask >>= 1
    if input[input_length - 2] == '=':
        output_len -= 1
        input_mask >>= 1

output_mask := bzhiq(-1, output_len)

bzhiq means "zero high bits starting at bit position index", and when index is 64 or greater it changes nothing and returns the source unchanged. output_len is a signed integer: when the remaining input looks like =, ==, X=, X== or XY=, the (input_length / 4) * 3 term evaluates to 0 and then padding subtracts 1 or 2, landing on -1 or -2. Passed to bzhiq, -1 read as unsigned is an enormous number, so the mask comes back as all ones and evmovdqub writes the full 64 bytes.

The 65-byte input makes the arithmetic concrete. The first 64 characters are consumed as a full block producing 48 bytes, leaving a single = at offset 48. Total buffer length is ceil(65/4)*3 - 1 = 50. An all-ones mask writes 64 bytes starting at 48, ending at 111, which is 62 bytes past the end. Order matters: the Java-level validation runs after the intrinsic returns, so by the time the exception is thrown the damage is already done. That IllegalArgumentException in the log does not mean nothing happened.

Porting the mask logic to plain Python makes the overflow visible without any AVX-512 hardware:

M64 = (1 << 64) - 1


def bzhiq(src, index):
    if index < 0 or index >= 64:
        return src & M64
    return src & ((1 << index) - 1)


def run_tail(tail, head=64):
    total_in = head + len(tail)
    pad = tail.count(b"=")
    buf_len = ((total_in + 3) // 4) * 3 - pad
    output_len = (len(tail) // 4) * 3
    if tail.endswith(b"="):
        output_len -= 1
        if tail.endswith(b"=="):
            output_len -= 1
    written = bin(bzhiq(M64, output_len)).count("1")
    last = 48 + written - 1
    return buf_len, output_len, written, last, last - (buf_len - 1)


print("%-5s %-7s %-10s %-6s %-9s %s" % ("tail", "buf_len", "output_len", "bytes", "last_byte", "past_end"))
for tail in [b"=", b"==", b"X=", b"X==", b"XY=", b"===", b"XYAB"]:
    b, ol, w, last, over = run_tail(tail)
    print("%-5s %-7d %-10d %-6d %-9d %d" % (tail.decode(), b, ol, w, last, over))
$ python mask_sim.py
tail  buf_len output_len bytes  last_byte past_end
=     50      -1         64     111       62
==    49      -2         64     111       63
X=    50      -1         64     111       62
X==   49      -2         64     111       63
XY=   50      -1         64     111       62
===   48      -2         64     111       64
XYAB  51      3          3      50        0

The first six rows are the same class of degenerate tail, each writing the full 64 bytes and overshooting by 62 to 64. The last row is a legal four-character tail writing 3 bytes with no overflow. Note that X= and X== differ not in the sign of output_len but in the buffer being one byte shorter; the overshoot is always the gap between how much room is left and how much gets written.

One more detail shapes exploitation: only byte 0 is fully controlled, byte 1 has 4 controllable bits, bytes 2 through 63 are not controllable at all, and bytes 48 through 63 are always 0x9a. This is not an arbitrary write. It is a write with a controllable landing spot and mostly fixed content.

3. The attack surface is wider than one API

The bug lives in the decoder, so every path that reaches Base64 decoding is an entry point. Calif demonstrated pre-auth RCE in Keycloak, Atlassian Jira and Confluence, JFrog Artifactory, Jenkins and PingFederate; post-auth in Kafka Broker, Solr, Elasticsearch, Gerrit and Spinnaker. Sample Struts and Spring Boot apps reproduced it through ordinary features like login and file upload.

The client side is the counterintuitive part: a Java program that merely connects to a malicious TLS server is compromised even though it exposes no port at all (samczsun contributed the client-side exploit). The reason is mundane. Certificate chains, JWT, SAML assertions and bearer tokens are all Base64-wrapped, and decoding them is routine on the client.

So "we do not expose a Base64 endpoint" is not a conclusion. Three questions actually matter: does the process decode Base64, can external input reach it, and is the host x86-64 with AVX-512 VBMI. The first two are almost always yes. The third removes most of the fleet, because consumer Intel parts dropped AVX-512 from Alder Lake onward, which means developer laptops and CI runners are naturally immune while the production Xeon and EPYC fleet is fully exposed. That combination is nasty: it does not reproduce locally and it hits everywhere in production.

4. What sits between triggering and RCE

The overflow writes fixed bytes, so Calif builds two primitives out of it. First, a writer: overwrite a buffer length field so it accepts arbitrary bytes, turning the fixed write into a bounded linear write with selectable values. Second, a reader: corrupt another array length and get its contents echoed into a response, leaking heap data (they call it JavaBleed: PII, private keys, tokens). In between sits heap grooming, since G1 divides the heap into fixed-size regions and the key arrays have to leave the thread-local TLAB and take the outside-TLAB allocation path, plus multiple writer/reader pairs sprayed in parallel.

Remote heap grooming is the hard part: send a request in fragments, wait for TCP acknowledgement before controlling the next allocation, then finish the request. It is extremely sensitive to RTT and jitter. There is one thing in the writeup that looks like a universal fix and is not: nginx buffers request bodies by default, which appears to defeat fragmentation. But Elasticsearch runs the whole exploit from a single complete request, and frames after a WebSocket upgrade travel through a tunnel and never touch body buffering. Calif states plainly that request buffering is not a general mitigation.

Their phase breakdown works well as a checklist for judging whether a target is really exploitable: WARM (repeated legal decoding so the JIT picks the affected fast path, without corrupting memory), REHEARSE (safe calibration pass for timing), TRIGGER (send the malformed tail), DISCLOSE (amplify the reader and collect heap bytes from responses), REPAIR (restore headers and untouched neighbours using leaked originals), FINISH (apply the target-specific change and verify through a real request). There is no universal payload; every target needs its own profile.

5. Three things you can do tonight

OpenJDK published an advisory at 13:00 PT on 2026-11-17 and Oracle shipped its patch batch at the same time. So the first item is not a discussion: upgrade to the patched build. The hard part is the fraction of the fleet that cannot be upgraded this week.

The second item is the temporary mitigation, one of two flags on the command line:

# Disable the hardware-accelerated codecs. Safest; cost lands on Base64 hot paths only.
-XX:-UseBASE64Intrinsics

# Or cap AVX at AVX2. x86-64 hosts only.
-XX:UseAVX=2

The second one deserves a warning repeated three times: x86-64 only. OpenJDK on ARM does not recognize that flag and will refuse to start. In a mixed fleet (some Graviton, some Xeon) sharing one JVM options template, that flag takes down every ARM node at once, and you find out after the restart. Scope it per environment, or just use the first flag everywhere.

The third item is inventory, judged on version and hardware together. On each host, pull the CPU flags and the JDK version, then correlate:

# All four flags must be present on x86-64. Output of 4 means exposed.
grep -m1 '^flags' /proc/cpuinfo | grep -oE 'avx512f|avx512bw|avx512vbmi|bmi2' | sort -u | wc -l

# Coarse version filter. Note JDK 17 needs 128 A characters, 21+ needs 64.
java -XshowSettings:properties -version 2>&1 | grep 'java.version'

A result of 4 means exposed; 0 through 3 means not. Put this in a script rather than a wiki page, because a wiki goes stale and a script asks the machine again every time it runs.

6. Two things worth remembering from this disclosure

The first is cost. Calif researcher Quang Luong found the bug in about an hour, had a working exploit two hours later, and spent under 200 dollars in tokens using GPT-6 Cyber. That number is more concrete than any AI security report I have read this year: a CVSS 9.2 flaw affecting Keycloak and Jenkins, from nothing to reproducible exploit, now costs less than a team lunch.

The second is about patches themselves, and it is worse. On the same day, Google's threat intelligence group reported observing attackers writing exploit code directly from patches: vendors change a few lines, AI stares at those lines, and the vulnerability falls out. Stack the two together and you have a pipeline. A patch release is a public hint, and AI converts it into an exploit within hours. The old rhythm of internal canary first, fleet-wide upgrade two weeks later now hands an opponent a two-week head start.

Calif closes with an idea I find persuasive, which they call vibe uncoding: instead of asking what else can be built, ask what can be deleted. Dead code, unused features, optimization paths that exist for three percent of traffic. Code you delete cannot produce a CVE. This Base64 intrinsic is the archetype. Its entire value was making decoding a bit faster, and the price was a 9.2.

For prioritization today: if you run Keycloak, Jenkins, Confluence or Artifactory on x86-64, add -XX:-UseBASE64Intrinsics now and schedule the upgrade, do not wait for a window. If your hardware has no AVX-512, you can watch this one from the sidelines, but write the two-condition rule into your next triage runbook. The lesson here is not that Java has a bug. It is that version numbers lie.

Further reading

Commentaires

Ce site est uniquement frontal : pas de backend ni de compte. Les commentaires vont sur GitHub Issues, Discussions ou par e-mail.

Collez ceci dans l'issue ou l'e-mail pour m'aider à localiser le problème ; cela n'inclut rien de ce que vous avez saisi

Aussi :Voir les commentaires existants · Commentaires par e-mail (sans compte GitHub) :278975598@qq.com