Skip to content

Latest commit

 

History

History
306 lines (223 loc) · 13.5 KB

ANALYSIS.md

File metadata and controls

306 lines (223 loc) · 13.5 KB

Java4Shell — CVE-2026-114938 — Full Analysis

Produced by Opus 5.5 on day of disclosure (2026-11-17). All findings grounded in primary sources fetched and cross-checked.

1. At a glance

Field Value Source
CVE CVE-2026-114938 OpenJDK advisory, Oracle CPU
Nickname Java4Shell calif.io, JFrog
Class Heap out-of-bounds write → info disclosure / RCE calif.io
Component hotspot/compiler (C2 JIT intrinsic) OpenJDK advisory
Vulnerable fn StubGenerator::generate_base64_decodeBlock(), src/hotspot/cpu/x86/stubGenerator_x86_64.cpp fix commit
Root cause AVX-512 VBMI Base64 decode tail: pad-driven output_size underflow → bzhiq full mask → full 64-byte evmovdqub store source+commit
Fix JDK-8393212, commit 5177a70b385c (2026-11-16): 3-line length<4 guard openjdk/jdk
CVSS v4.0 / v3.1 9.2 Critical / 8.1 High (AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H) calif.io / OpenJDK
Affected OpenJDK 17, 21, 25, 27 (17.0.6+) advisory, calif.io
Affected Oracle Java SE 8u511b33-perf, 17.0.21.0.3, 21.0.13.0.3, 25.0.5.0.3, 27.0.1.0.3 Oracle CPU
HW precondition x86-64 with avx512f,avx512bw,avx512vbmi,bmi2; ARM64 not affected calif.io
Credits Quang Luong (Calif.io), Jenish Rakholiya; Albert Yang (Oracle ack) calif.io, Oracle

2. Timeline & credits

  • 2021-06-25 — JDK-8268276: AVX-512 Base64 intrinsic committed to OpenJDK mainline (author: Scott Gibbons)
  • 2022-11 — JDK-8296735: Backport to JDK 17 resolved (ships in 17.0.6, January 2023)
  • 2023-12 — JDK-8321599: Related "data loss in AVX3 Base64 decoding" bug fixed (distinct from this CVE)
  • 2026 (date unreported) — Quang Luong discovers CVE-2026-114938 using AI-assisted review (~1 hour to find, ~2 more hours to first exploit, <$200 in tokens)
  • 2026-10-13 — Fix authored by Tobias Hartmann (commit 5177a70b385c)
  • 2026-11-16 19:52 UTC — Fix lands in master as 5177a70b385c under benign title "8393212: Base64 optimization improvements"
  • 2026-11-17 ~13:00 PT — OpenJDK advisory, Oracle CPU, and calif.io disclosure publish together
  • 2026-11-17 ~19:20 UTC — Independent reproduction by Upwind (confirmed overflow on Ice Lake)

Credits: Calif.io credits Quang Luong (research/writeup/exploits) and Jenish Rakholiya (exploit improvement). Oracle acks Quang Luong (Calif.io) and Albert Yang. Artwork by Michal Zalewski.


3. Vulnerable component

  • Intrinsic generated by generate_base64_decodeBlock() (fn @ L3155 of current master), wired as StubRoutines::_base64_decodeBlock, intrinsifying java.util.Base64$Decoder.decodeBlock.
  • Three engines: (1) AVX-512 VBMI fast path with masked evmovdqub stores — vulnerable; (2) AVX2 fallback; (3) L_bruteForce scalar 4-byte decoder — bounds-correct.
  • Only emitted when CPU has AVX-512 VBMI (Intel Ice Lake/Sapphire/Emerald/Granite Rapids; AMD Zen 4+). ARM64 / non-VBMI x86 immune.
  • Must be JIT-compiled: a cold/interpreted decode is safe; exploits and the PoC must warm the intrinsic first (~200k iterations).

Trigger conditions

Condition Requirement
CPU x86-64 with AVX-512 VBMI + BW + F and BMI2
JDK version >= 17.0.6 (any distribution)
JIT state C2 must have compiled the Base64 intrinsic
Decoder type Basic decoder (Base64.getDecoder()) or URL decoder (Base64.getUrlDecoder())
NOT affected MIME decoder (Base64.getMimeDecoder()) bypasses this path
Input Malformed Base64 ending in = with tail length 1-3 bytes past a 64-byte boundary

Version-specific triggers

Java Version Trigger String
17 (17.0.6+) "A" * 128 + "=" (129 bytes)
21, 25, 27 "A" * 64 + "=" (65 bytes)

4. Root cause (trace against real source)

Line numbers from post-fix master; pre-fix layout identical minus the 3 guard lines.

Tail handler at L_finalBit (1–63 bytes left):

__ BIND(L_finalBit);
// FIX (JDK-8393212):
__ cmpl(length, 4);
__ jcc(Assembler::less, L_bruteForce);
// ---
__ movq(rax, -1);
__ bzhiq(rax, rax, length);                 // input mask (L3405-3406)
__ movl(output_size, length);
__ shrl(output_size, 2);                     // length/4
__ lea(output_size, Address(output_size, output_size, Address::times_2, 0)); // *3
__ addq(length, start_offset);
__ cmpb(Address(source, length, Address::times_1, -1), '=');
__ jcc(Assembler::equal, L_padding);
__ BIND(L_donePadding);
__ subq(length, start_offset);
__ kmovql(input_mask, rax);
__ movq(output_mask, -1);
__ bzhiq(output_mask, output_mask, output_size);  // OUTPUT MASK
...
__ kmovql(k1, output_mask);
__ evmovdqub(Address(dest, dp), k1, tmp, true, Assembler::AVX_512bit); // STORE

Padding adjuster:

__ BIND(L_padding);
__ decrementq(output_size, 1); __ shrq(rax, 1);          // one '='
__ cmpb(Address(source, length, Address::times_1, -2), '=');
__ jcc(Assembler::notEqual, L_donePadding);
__ decrementq(output_size, 1); __ shrq(rax, 1);          // two '='

The underflow chain

  1. Input: "A"×64 + "=" → after processing the first 64-byte block, 1 byte remains (the lone =)
  2. Output size calc: output_size = (1/4)*3 = 0
  3. Padding adjustment: decrementq(output_size, 1) → output_size = -1 (0xFFFFFFFFFFFFFFFF)
  4. BZHI behavior: bzhiq(-1, 0xFF…) — BZHI uses only index[7:0] = 0xFF = 255. Since 255 ≥ 64 (register width), no bits are cleared → mask = 0xFFFFFFFFFFFFFFFF (all ones)
  5. Masked store: evmovdqub with all-ones mask writes all 64 bytes of the ZMM register
  6. Buffer math: Allocated buffer is 50 bytes, write starts at offset 48 → offsets 48–111 written → 62 bytes past the buffer end
  7. Exception: IllegalArgumentException is thrown after the write — the damage is done

Write contents

  • Byte 0: fully controlled
  • Byte 1: 4 bits controlled
  • Bytes 2–47: uncontrolled (decoded garbage)
  • Bytes 48–63: always 0x9A
  • A positioned, mostly-fixed 64-byte smear

5. The patch

Commit

  • Hash: 5177a70b385c
  • Bug ID: JDK-8393212: "Base64 optimization improvements" (benign title for embargoed fix)
  • Authors: TobiHartmann, albertnetymk
  • Authored: 2026-10-13, Committed: 2026-11-16
  • Reviewed by: rhalade (Oracle Security), mschoene, chagedorn, rcastanedalo
  • Change: +3 lines, 0 removed in stubGenerator_x86_64.cpp

The diff

@@ 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);

Why it works

The underflow only occurs when the tail is shorter than one complete 4-byte Base64 block (1–3 bytes). Guaranteeing length ≥ 4 before the masked path keeps output_size ≥ 3 after (n/4)*3, and the maximum padding adjustment is -2, so the minimum output_size for n ≥ 4 is 1 (never negative). Short tails divert to the bounds-correct L_bruteForce scalar decoder.

Edge cases

  • Fix does NOT add bounds checking to evmovdqub itself — a future code change could reintroduce similar
  • Fix does NOT address that BZHI silently wraps on out-of-range indices (x86 architectural behavior)
  • Fix IS sufficient: (n/4)*3 for n ≥ 4 always ≥ 3, minus at most 2 = minimum 1

Related prior fix

JDK-8321599 ("Data loss in AVX3 Base64 decoding", December 2023) — different bug in same intrinsic, incorrect source-offset causing data loss but NOT memory corruption.


6. Exploitation technique

From Calif.io disclosure. Weaponized chains withheld; treat details as unverified.

6.1 Writer primitive

The 62-byte overflow corrupts an adjacent Java array's length field. The JVM then permits reads/writes beyond the array's true bounds. This upgrades a fixed-value overflow into a bounded, chosen-value linear write. Classic technique from JS engine exploitation.

6.2 Reader primitive ("JavaBleed")

Using the writer, corrupt a second array's length field. This reader array's contents are copied into an HTTP response, including heap data beyond the original bounds. Heartbleed-style disclosure — PII, session tokens, private keys.

6.3 Heap Feng Shui

G1 GC divides heap into fixed-size regions. Each thread gets a TLAB (private Eden slice). Attackers spray writer/reader pairs, use padding allocations to control layout, and retry on misses. Custom heap tracer/visualizer built to help the AI agent reason about heap state.

6.4 Remote grooming

Request data sent in stages, waiting for TCP ACKs between stages to control allocation timing. Low, stable RTT preferred (Calif rented a VM in the target's region). nginx proxy_request_buffering can break timing for some chains but does NOT stop Elasticsearch. WebSocket frames bypass body buffering.

6.5 The six-phase chain

Phase Action
WARM Valid Base64 decodes → trigger C2 JIT compilation of AVX-512 intrinsic
REHEARSE Optional calibration round without corruption
TRIGGER Malformed tail → 62-byte overflow corrupts writer array's length
DISCLOSE Extend writer → corrupt reader → heap disclosure via response
REPAIR Restore damaged headers/neighbors using disclosed original values
FINISH Application-specific action, verify via live request

6.6 Why NOT universal

Each target needs a bespoke profile: different allocation patterns, TLAB sizes, GC behavior, network stacks, auth flows. Probabilistic — multiple attempts may be needed. Failed attempts can crash the JVM.


7. Affected products & versions

JDK versions

Java Line Vulnerable Range First Fixed
17 17.0.6 – 17.0.21 17.0.21.1
21 All before 21.0.13.1 21.0.13.1
25 All before 25.0.5.1 25.0.5.1
27 All before 27.0.1.1 27.0.1.1
11 Not affected N/A
8 Only Oracle SE 8u511b33-perf N/A

Hardware

CPU Family AVX-512 VBMI? Affected?
Intel Ice Lake+ (Xeon 3rd–6th Gen) Yes Yes
AMD EPYC Zen 4+ / Ryzen 7000+ Yes Yes
Intel Skylake/Cascade Lake No VBMI No
AMD Zen 1–3 No No
ARM64 (Graviton, Apple Silicon) No No
Any CPU under QEMU/Rosetta No emulation No

Demonstrated targets

Pre-auth RCE: Keycloak, Jira, Confluence, Artifactory, Jenkins, PingFederate

Post-auth RCE: Kafka, Solr, Elasticsearch, Gerrit, Spinnaker

Client-side: Java TLS client → malicious server (samczsun)


8. Detection

# CPU check (Linux) — all four flags required
grep -m1 '^flags' /proc/cpuinfo | tr ' ' '\n' | grep -E '^(avx512f|avx512bw|avx512vbmi|bmi2)$'

# Java version check
java -version 2>&1

# Running JVM
jcmd <PID> VM.version
jcmd <PID> VM.flags -all | grep -E 'UseAVX|UseBASE64Intrinsics'

# Definitive: run the PoC
javac Base64Trigger.java && java Base64Trigger

Log indicators: IllegalArgumentException from Base64, hs_err_pid*.log crash files, SIGSEGV in G1 GC, StubRoutines in crash stacks.


9. Mitigation

Upgrade (primary) → restart all JVMs, rebuild containers.

Interim — disable Base64 intrinsic (recommended):

java -XX:-UseBASE64Intrinsics MyApp

Interim — disable AVX-512 (broader, x86-64 only):

java -XX:UseAVX=2 MyApp   # DO NOT use on ARM — JVM fails to start

10. Comparison

Heartbleed Log4Shell Spring4Shell Java4Shell
Bug class Over-read Injection Class manipulation Integer underflow → heap overflow
Exploitation Trivial Trivial Moderate Complex, probabilistic
Universality Any OpenSSL Any Log4j 2.x Spring+Tomcat+JDK9 Per-target + HW-gated
HW dependency None None None AVX-512 VBMI
CVSS 7.5 10.0 9.8 8.1–9.2

Novelty: Root cause in JIT-emitted assembly — invisible to Java SAST and dependency scanners. Exposure = runtime build + CPU, not classpath.


11. References


Product-specific exploitation chains withheld by Calif.io pending patch adoption.