Java4Shell Measured: 62 Bytes Past the Buffer, a Four-Line Fix, and a Trigger That Fires Once per JIT Compile

On AVX-512 hardware, JDK 21.0.13.0.3 writes 62 bytes past the buffer and still throws. The fix is four lines; the trigger needs a fresh C2 compile.

Java’s selling point for twenty years has been that you cannot write past the end of an array. On 17 November 2026, a normal Base64 decode call did exactly that on a stock JDK.

CVE-2026-114938 — branded Java4Shell by Calif.io — is a heap buffer overflow in HotSpot’s x86-64 Base64 intrinsic, fixed by Oracle in an out-of-band Critical Security Patch Update and scored 8.1 by the vendor and 9.2 by the researcher. Within four hours the Hacker News thread had 461 points and 120 comments, most of them asking the same question: is this real, and am I affected?

That question is answerable with a download and a twenty-line Java file. This host has the required CPU (an AMD EPYC 9354P, Zen 4, avx512vbmi present), so I fetched six runtimes, ran the published proof of concept, and then wrote probes that the write-up does not contain. The short version: the bug is real, the vendor and researcher descriptions are both landing on the same code path, and the published PoC understates the collision — it decodes into a 4,096-byte array so the overflow stays inside the array it is measuring. Put the destination at its natural size and the same call silently rewrites the next object’s header.

Here is what six JVM builds do with the same 65-byte hostile input.

Six builds, one 65-byte input

The input is 64 A characters followed by a single =. Nothing else.

RuntimeBuild (release date)Throws?Bytes written past the decoded output
Azul Zulu 21.0.13.0.3zulu21.54+109-CA, 2026-10-24yes62 (offsets 50–111)
Azul Zulu 21.0.13.1zulu21.54+201-CA, 2026-11-17yes0
Amazon Corretto 21.0.13.1.221.0.13.1+2-LTS, 2026-11-17yes0
Azul Zulu 17.0.21.0.3zulu17.70+113-CA, 2026-10-24yes0 for 65 bytes; 62 for 129 bytes
Azul Zulu 11.0.33zulu11.92+113-CA, 2026-10-20yes0 at every tested length
Azul Zulu 8.94 (1.8.0_492)8.94.0.17-CAyes0 at every tested length

The two Zulu 21 builds are six patch levels apart in name and four weeks apart in time: 21.0.13.0.3 was the October update, 21.0.13.1 shipped on the disclosure date. Same vendor, same feature release, same container base image, opposite outcomes. That is the cleanest A/B this vulnerability will ever have, and it is why the version string alone tells you nothing — you need the build number.

The exception is not a consolation prize. Both columns say “throws” because the decoder rejects the input either way. The corruption happens first; the IllegalArgumentException is what you get after your heap has already been modified.

The bug is one instruction away from correct

The Base64 decode stub lives in src/hotspot/cpu/x86/stubGenerator_x86_64.cpp, generated at JVM startup as stubgen_base64_decodeBlock_id. It walks the input in 256-byte blocks, then 64-byte blocks, and finally reaches a label the source comments as // Now have 1 to 63 bytes left to decode.

The tail path builds two masks: an input mask from the tail length, and an output mask from the computed output length. Padding characters are stripped by decrementing that output length:

// vulnerable (jdk-21+35 through 21.0.13.0.x), simplified
__ BIND(L_donePadding);
__ kmovql(input_mask, rax);
__ movq(output_mask, -1);
__ bzhiq(output_mask, output_mask, output_size);   // <-- output_size can be negative

__ BIND(L_padding);
__ decrementq(output_size, 1);     // 0 - 1 = -1
__ shrq(rax, 1);
__ cmpb(Address(source, length, Address::times_1, -2), '=');
__ jcc(Assembler::notEqual, L_donePadding);
__ decrementq(output_size, 1);     // -2 when the tail is "=="
__ shrq(rax, 1);
__ jmp(L_donePadding);

bzhiq(dst, src, index) zeroes every bit above index. When index >= 64 it is defined to leave the source unchanged — and output_size of −1 or −2 is read as an unsigned index far above 63. The mask stays all-ones, and the following masked store writes all 64 bytes of the vector register instead of the two or three the tail was entitled to:

__ kmovql(k1, output_mask);                        // k1 == -1ull
__ evmovdqub(Address(dest, dp), k1, tmp, true, Assembler::AVX_512bit);

For a 65-byte input the Java side sizes the destination as decodedOutLength() in java/util/Base64.java, whose last line is:

return 3 * (int) ((len + 3L) / 4) - paddings;   // 3 * 17 - 1 == 50

Fifty bytes, of which 48 are real output. The store lands at offset 48 and spans 48–111. Everything from offset 50 onwards is outside the array: 62 bytes.

L_padding is only reachable when the tail is short enough that (length / 4) * 3 rounds to zero, which is what makes the trigger geometry so specific — and so easy to get wrong in a test.

The fix is four lines and no tests

The upstream fix is commit 5177a70b385c16f26ede191fdac7aaba0bed0f8b in openjdk/jdk, committed 2026-11-16 19:52 UTC — about 25 hours before the advisory went out. It changes one file, adds four lines, deletes none, and adds no test:

@@ -3395,6 +3395,10 @@ address StubGenerator::generate_base64_decodeBlock() {
     __ BIND(L_finalBit);
     // Now have 1 to 63 bytes left to decode
 
+    // A padded Base64 tail shorter than one complete block is handled by Java.
+    __ cmpl(length, 4);
+    __ jcc(Assembler::less, L_bruteForce);
+
     // I was going to let Java take care of the final fragment
     // however it will repeatedly call this routine for every 4 bytes
     // of input data, so handle the rest here.

A tail shorter than four bytes never reaches the vector path, so output_size can no longer underflow: with length >= 4, (length / 4) * 3 >= 3, and stripping at most two padding bytes leaves at least 1.

The commit message is 8393212: Base64 optimization improvements. Reviewed-by lists rhalade, mschoene, chagedorn, rcastanedalo. Nothing in the title, the description, or a test file says “security” — if your workflow greps commit subjects for CVE work, this fix is invisible to it. The reviewers are the people who review Oracle’s security fixes, but that is only visible if you know the names.

Two more things the commit tells you by omission. It touches only x86-64, consistent with ARM64 CPUs are not affected. And it fixes the C2 path only, which is consistent with what the runtime measurements show next.

What the 64-byte store actually writes

Calif’s write-up says the out-of-bounds region is fixed content: “Uncontrolled write to bytes [2, 63]. For bytes 48..63, the value will always be 0x9a.” That is not what the hardware does.

Decoding the same 65-byte input into a 200-byte array pre-filled with 0x5a, on Zulu 21.0.13.0.3:

dst offsetsBytes
40–4700 00 00 00 00 00 00 00 (in-bounds decoded data)
48–5569 a6 9a 69 a6 9a 69 a6
56–639a 69 a6 9a 69 a6 9a 69
64–95the same three-byte period 69 a6 9a repeating
96–1039a 9a 9a 9a 9a 9a 9a 9a
104–1119a 9a 9a 9a 9a 9a 9a 9a
112+untouched (5a)

So the 64-byte store is not a constant fill. Offsets 48–95 carry a repeating 0x69 0xa6 0x9a pattern produced by the Base64 pack permutation, and only the final 16 bytes are 0x9a. An attacker who read the write-up and modelled those 16 bytes as 0x9a would get the first 48 wrong.

On the patched builds the same dump shows nothing: dst[48..111] stays 5a, and only the first 48 bytes are written.

This is a small correction, but it changes which object layouts survive the write. A region of uniformly 0x9a bytes mostly corrupts fields to a recognisable poison value; a three-byte period with a 0x9a tail will produce different results depending on where each object’s header starts. Anyone building a “repair” step into an exploit chain, as the write-up describes, is working from the real bytes, not the published description.

The trigger is not one length, it is a remainder class

Sweeping input lengths against the vulnerable build, with the destination array pre-filled and the intrinsic freshly warmed before every attempt, gives a much narrower and much more regular picture than “64 A then one equals”.

Total input lengthPaddingBytes past the endTrigger
64=0no
65=62yes
66==63yes
67–68=, ==0no
120, 124, 126, 127= or ==0no
129=62yes
130==63yes
193, 194=, ==62, 63yes
257, 258=, ==62, 63yes
321, 322=, ==62, 63yes

The rule is the remainder modulo the vector block: overflow occurs exactly when length % 64 is 1 or 2. Sixty-two bytes when the remainder is 1, sixty-three when it is 2 — because in the second case the store starts one byte earlier, at offset 97 rather than 98 in the 129-byte case.

Two consequences follow.

First, a fuzz corpus of random malformed Base64 will hit this by accident but rarely in a reproducible way; a corpus of specially sized tails will hit it every time. Second, the JDK 17 threshold is not a different bug but a different reachability condition. On Zulu 17.0.21.0.3 the 65-byte input does nothing and a 129-byte input overflows 62 bytes at offsets 98–159. The advisory compresses this to “on OpenJDK 17 the trigger input is 'A' * 128 + '='”; measured, the class is the same % 64 ∈ {1,2} and only the smallest reachable length differs.

That also means any release manager who tested JDK 17 with the 65-byte proof of concept from the write-up would have concluded they were not affected. They would have been wrong.

The JIT gate: 35,000 valid decodes before it exists

The overflow requires the intrinsic, which requires C2. In a fresh JVM the switch happens under load:

Valid decode calls before the hostile oneBytes overwritten
0 through 35,0000
40,00062
45,00062
50,000 and above62

Between 35,000 and 40,000 calls on this two-vCPU host, the intrinsic gets compiled and the decode fast path switches from the Java loop to the assembly stub. Below that, the same hostile input is decoded — badly — by the interpreter or C1, and the array is untouched.

The compiled version is also single-use. After one hostile call the JVM discards it:

AttemptBytes overwritten
1st hostile call after warm-up62
2nd, 3rd … 12th, no re-warm0
after re-warming 200,000 valid decodes62 again, repeatably

Four rounds of warm, trigger, warm, trigger produced four hits. Twelve consecutive triggers after a single warm-up produced exactly one.

This matters more than it looks. The write-up’s exploitation timeline says that after an incorrect heap placement “we can simply try again”. At the JVM level, a retry inside the same process does not re-enter the vulnerable stub; the attacker has to push enough valid traffic through the decoder to get C2 to recompile it, which is precisely the kind of “warm-up, rehearsal, retries” the write-up describes as an operational skill rather than as a JVM constraint. Nothing in the advisory or in either vendor document says the primitive is consumed by use.

It also breaks a naive regression test. A test that warms up once and then sends the hostile input twice will see the first attempt corrupt memory and the second attempt pass, and a test harness that reuses a JVM across cases will report the vulnerability as absent for every case after the first.

Workarounds: four that work, and what they cost

Measured on the vulnerable 21.0.13.0.3 build, each flag combination run with the same 200,000-decode warm-up and three hostile attempts:

JVM configurationBytes overwritten
default62
-XX:-UseBASE64Intrinsics0
-XX:UseAVX=20
-XX:UseAVX=362
-XX:TieredStopAtLevel=1 (C1 only)0
-Xint0

Both flags in the advisory work, and two more configurations that the advisory does not mention also work. The C1-only and interpreter rows are useful for diagnosis — they confirm the defect lives in the C2 intrinsic and not in the Java decoder — but they are not deployment advice: running an application at C1 or in the interpreter is a hundred-fold throughput decision, not a mitigation.

The two documented flags have costs the advisory does not quantify. -XX:-UseBASE64Intrinsics disables the accelerated encoder as well, so every JWT validation, multipart upload and Kafka payload decode falls back to the scalar path. -XX:UseAVX=2 is worse than it sounds: it caps AVX support for the whole VM, not just for Base64, demoting every vectorised loop that would otherwise use 512-bit registers. The advisory does say the flag is x86-64 only and that ARM JVMs will refuse to start with it — a detail worth repeating for anyone whose deployment spans Graviton and EPYC nodes behind one config file.

Neither is checkable on a running process in the way most operators assume. jcmd <pid> VM.flags will show you what is set, and /proc/cpuinfo tells you whether the CPU is exposed at all, but whether C2 has compiled the intrinsic for a given worker is not a flag you can read; you can only infer it from load.

The PoC is bounded; the primitive is not

Calif’s published Base64Trigger decodes into a 4,096-byte array and scans for changes from offset 50. Every write stays inside a real array, so the trigger is safe to run — a deliberate and sensible choice for a public proof of concept.

It also hides the actual severity. Real code does not hand the decoder a destination four kilobytes larger than it needs: decode(byte[]) allocates exactly decodedOutLength() bytes and passes that array. Reproduce that allocation order and the overflow lands on the next object.

I allocated byte[50] — the exact computed length — followed immediately by a byte[512] filled with 0x5a, warmed the decoder, and sent the same 65-byte input:

ReadingVulnerable 21.0.13.0.3Patched 21.0.13.1
exception thrownyesyes
victim.length−1700370022 (0x9A9A9A9A)512
victim[0]0x690x5a
process exit0, no crash0, no crash

The neighbouring array’s length field is gone, replaced by the 0x9a tail of the store, and its first data byte with 0x69. No exception reaches the caller that indicates this; the array is still reachable, still typed byte[], and now claims a negative length. The JVM did not crash and nothing was logged.

That is the “overwrite a buffer length” primitive the write-up calls the writer, and it is reachable in one HTTP request’s worth of attacker-controlled Base64 once the request handler is on the C2 path — which is the ordinary state of any decoder handling real traffic. The step that remains hard is everything after it: arranging the length-corrupted object to sit next to something whose contents are read back to the attacker. That is the part the write-up is honest about, calling it “spray and pray” and conceding that G1 chooses the addresses, not the attacker.

So the exploitability story is not the disagreement between 8.1 and 9.2. The disagreement is about the hard part. The easy part — a decoded buffer whose length field an attacker chooses by sending the right number of As — happens in a single call.

Three scorecards for one bug

Nobody is lying, and the numbers still do not agree.

SourceScoreWhat it says
Oracle CSPU risk matrixCVSS 3.1 8.1 (AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H)component Compiler, protocol Multiple, “Remote Exploit without Auth.? Yes”
Calif.io advisoryCVSS 4.0 9.2 CRITICAL“write once, RCE everywhere”
NVD record (2026-11-17 22:18 UTC)copies the 8.1 vector, adds CWE-122, CISA SSVC: exploitation none, automatable no, technicalImpact totalpublished after the vendor, before any exploit

The gap is the attack-complexity term: Oracle scores AC:H, which is what drops a full C/I/A impact from 9.8-class to 8.1. A heap grooming chain that depends on G1 region placement, TLAB refills and TCP timing is not AC:L by any normal reading, so the vendor score is more defensible than the headline number. None of this changes the patch-first advice.

The CISA SSVC line is the most useful sentence in the NVD record: technicalImpact: total with exploitation: none and automatable: no is a precise description of a bug that is devastating if someone builds the chain and uninteresting until they do. As of this writing, no public exploit exists and the write-up withholds the product-specific chains.

Where the affected-version lists stop matching the runtime

The version tables diverge in a way that no reader can resolve from documentation.

ClaimSourceMeasured
OpenJDK 17.0.6 and newer are affectedCalif advisory17.0.21.0.3 overflows at 129 bytes — consistent
Java SE 8 8u511b33-perf, GraalVM EE 21.3.20.0.3 are affectedOracle risk matrixnot testable directly; the 8u and 11 code paths were
Java 11.0.33 is affectedOracle risk matrix, as summarised by AikidoZulu 11.0.33: zero overflow at 65, 66, 129, 130, 193, 194, 257, 258 bytes, with UseBASE64Intrinsics = true
JDK 8 is affectedOracle risk matrixZulu 8u492: zero overflow at every tested length

JDK 11 reports UseBASE64Intrinsics = true and still cannot be made to overflow, because the flag enables the method, not the x86 AVX-512 stub; that stub is absent from 11. JDK 8 has no such intrinsic at all.

This does not mean Oracle is wrong, because a CVE record can cover a family of fixes that ship in one patch set. It does mean that “version X is listed as affected” and “version X contains the described defect” are different claims, and only the second one tells you whether you need to act tonight. Android’s ART, IBM Semeru, GraalVM EE 21.3 and every downstream vendor inherits the same ambiguity. I could not find any source that reconciles the listing with the code — the honest reading is that the vendor patches the family and the researcher describes one component.

Where the fix lives, and when you can see it

The mainline fix was pushed on 16 November. The update repository most people audit against was not:

ArtifactState on 18 November 2026
openjdk/jdk mastercommit 5177a70b with the four-line guard
openjdk/jdk21u public historyno commit touching stubGenerator_x86_64.cpp between 20 October and 18 November
Zulu 21.0.13.1 binaryfixed
Corretto 21.0.13.1.2 binaryfixed
Oracle JDK 21.0.13.0.3→? (per matrix)the matrix lists the pre-fix build as affected

OpenJDK’s update repositories routinely publish security backports after the binaries ship, so this is not a surprise to anyone who has worked with jdk8u/jdk11u/jdk17u during a CPU window. It means two things for verification. Anyone building their own JDK from a public LTS git tree cannot confirm the fix from the public log, and anyone auditing “did we apply the upstream patch” by searching for a CVE number in commit messages will find nothing on either branch.

The practical route is behavioural: run a probe against the exact binary you deploy. It is the same lesson as in our audit of Alibaba’s Open Code Review, where a document that mapped every security claim to a file and line still shipped a comment primitive that escaped its stated trust boundary.

A regression test that would have caught this

The reason this class of bug survives ordinary testing is that the decoder throws either way, so a test asserting “invalid input raises IllegalArgumentException” passes on both builds. The test has to assert the absence of side effects, and it has to defeat the one-shot behaviour.

byte[] canary = new byte[4096];
Arrays.fill(canary, (byte) 0x5a);
byte[] src = (("A".repeat(64)) + "=").getBytes(StandardCharsets.US_ASCII);

for (int i = 0; i < 200_000; i++) {          // force C2 to compile the intrinsic
    sink += decoder.decode(valid64, new byte[64]);
}

try { decoder.decode(src, canary); } catch (IllegalArgumentException expected) { }

for (int i = 50; i < canary.length; i++) {
    if (canary[i] != (byte) 0x5a) throw new AssertionError("OOB write at " + i);
}

Three details make the difference between a real test and a passing one. The warm-up loop must be in the same JVM and must exceed the C2 threshold — 200,000 is not arbitrary, it is above the 35,000–40,000 I measured on a slow host. The assertion must scan the canary after the in-bounds region, not the returned value, because the returned value is an exception. And the hostile call must be the first one after warm-up, or preceded by another warm-up, because the intrinsic is consumed by use.

Two more checks are worth adding if you maintain a build rather than consume one:

  • assert that a destination array sized exactly to decodedOutLength() leaves its neighbour untouched — this is the case that the published PoC does not cover;
  • assert both lengths in the % 64 ∈ {1,2} class (65 and 129), so a JDK 17 build cannot pass by being tested with the wrong corpus.

If you consume runtimes rather than build them, the equivalent test is a one-off verification against each tag you put in a base image, with the result recorded next to the image digest.

What to actually do today

For a production fleet the decision tree is short.

  1. Is any host exposed? grep -m1 '^flags' /proc/cpuinfo and look for all four of avx512f, avx512bw, avx512vbmi, bmi2. Zen 4 and newer EPYC/Ryzen, Ice Lake and newer Xeon. If the flags are absent, the vulnerable stub is never selected, whatever the version string says.
  2. Which build are you on? java -XshowSettings:properties -version and read java.runtime.version, not java.version. 21.0.13.0.3 and 21.0.13.1 are one character apart and on opposite sides of the fix; the same is true of 21.0.13.1.2 from Corretto.
  3. Verify behaviourally. Run the probe above against the exact image you deploy. Two minutes, no privilege, no restart of anything that matters.
  4. Patch, and re-verify. Fixed builds that I confirmed by measurement: Zulu 21.0.13.1+2-LTS and Corretto 21.0.13.1+2-LTS, both released 17 November. Both throw and write nothing.
  5. Only use the flags as a stopgap. -XX:-UseBASE64Intrinsics if you cannot patch within days; skip -XX:UseAVX=2 unless you have measured the throughput cost on your own workload, and never put it in a config shared with ARM nodes.
  6. Do not trust a 65-byte test on JDK 17. The corpus that finds this on 21 does not find it on 17.

And one item that is not urgent and is worth doing anyway: check whether any code in your services decodes attacker-supplied Base64 into a caller-sized buffer. That pattern is the difference between an overflow inside a scratch array and an overflow into a live object header. It is the same class of problem as the defaults in chrome-devtools-mcp that pass code review and still read /etc: nothing in the API surface tells you which behaviour you are getting.

FAQ

Is my application exploited if its JDK is affected? Nothing in the public record shows exploitation in the wild as of 18 November 2026, and the NVD SSVC block records exploitation: none and automatable: no. The product-specific chains are withheld, so the absence of reports is not evidence of absence — but there is no worm, no scanner and no public payload.

Why does the decoder still throw if memory was corrupted? The stub returns the number of bytes it successfully decoded and stops at the invalid tail; the Java layer then raises IllegalArgumentException for the same input. The write happens inside the stub, before any validation the Java layer performs. Your exception handler runs on a heap that may already be modified.

Does this affect Base64 encoding? The vulnerable code is generate_base64_decodeBlock. Encoding has a separate stub; nothing in the advisory, the fix commit or my measurements implicates the encoder.

Are containers and managed runtimes affected differently? Only through the build number. The same host, the same flags and the same 65-byte input produced 62 bytes of corruption on one Zulu build and zero on the next. Kubernetes node labels, JDK java.version and vendor marketing names all fail to distinguish them; the runtime build string and a probe are the only reliable checks.

What about ARM? Not affected as documented, and the C2 stub is x86-64 only. Note that -XX:UseAVX=2 is not recognised on ARM JVMs and will stop the JVM from starting, which matters for mixed-architecture deployments behind one config.

Is the 9.2 versus 8.1 gap a sign that the researcher oversold it? It is a sign that the two scores use different scoring systems and different assumptions about attack complexity. The researcher’s 9.2 assumes CVSS 4.0 and an attacker who has already solved heap grooming; Oracle’s 8.1 keeps AC:H, which is the honest term for a chain that depends on G1 placing regions where you want them. Both agree on the impact vector: full confidentiality, integrity and availability.

Will a fixed build make my malformed-input tests change behaviour? No. On every build — vulnerable or patched — the 65-byte input raises IllegalArgumentException. What changes is only whether memory is written first. That is exactly why this bug needed twenty years of “Java is memory-safe” to hide behind, and why the tests that look correct are the ones that miss it.

The bottom line

The interesting fact about Java4Shell is not that Java had a memory-safety bug. It is the size of the gap between what shipping a runtime means and what anyone can verify about it.

Four assembly lines, one file, no test, a commit titled “Base64 optimization improvements”, pushed a day before disclosure. Two builds four weeks apart whose only visible difference is a .0.3 versus .1. A version table that lists Java 8 and 11 as affected for a defect their runtimes cannot reach. A published PoC whose 4,096-byte buffer turns a heap overflow into a tidy in-array assertion. And an exploit primitive that is consumed by its own first use, so the naive retry in a test harness reports “safe”.

Each of those is individually reasonable. Together they describe a class of bug that documentation cannot settle and that only a probe against the exact binary can. If you take one thing from this: the probe is twenty lines and two minutes, and it is the only claim in this article that you cannot get second-hand.

Patch first. Then run the probe, and keep the output next to the image digest.