CVE-2026-114938, nicknamed **Java4Shell**, is a memory corruption vulnerability in OpenJDK's HotSpot JVM. The bug resides in the **AVX-512 accelerated Base64 decode intrinsic** — a performance optimization that the C2 JIT compiler substitutes for `java.util.Base64.Decoder` at runtime.
When a crafted Base64 string with specific padding is decoded on a CPU with AVX-512 VBMI support, an integer underflow causes the decoder to write **62-63 bytes past the end of the output buffer** on the Java heap.
**Key insight**: The vulnerability is NOT in Java application code or in `Base64.java` source code. It exists in the **native assembly code generated by the C2 JIT compiler** as a performance optimization. Developers writing correct Java code are still affected.
**Bug tracker**: JDK-8393212 ("Base64 optimization improvements")
The JVM executes Java bytecode through progressively faster compilation tiers:
Interpreter ← Executes bytecode line by line (slow, starts immediately)
C1 Compiler ← Quick compile, light optimization (level 1-3)
C2 Compiler ← Slow compile, aggressive optimization (level 4)
Native Code ← Runs directly on CPU, uses AVX-512 if available
C2 maintains a list of **intrinsics** — Java methods it replaces entirely with hand-written native assembly. `java.util.Base64.Decoder.decode()` is one of them. When C2 compiles this method, the original Java implementation is **completely bypassed**.
The bug exists only in C2's native assembly replacement, not in the Java source of `Base64.java`.
Standard Base64 decoding processes **4 input characters → 3 output bytes** per iteration.
The AVX-512 intrinsic processes **64 input bytes simultaneously** using SIMD instructions, achieving ~20x speedup. When input length exceeds 128 bytes and the CPU supports AVX-512 VBMI (Vector Byte Manipulation Instructions), C2 uses this accelerated path.
At the end of the input, any remaining bytes that don't fill a full 64-byte chunk are called the **tail**. The tail handler must:
1. Calculate how many output bytes the tail produces
2. Create a write mask to prevent writing beyond the output buffer
3. Execute a masked store that writes only the valid bytes
The tail handler computes output length roughly as:
output_len = tail_data_bytes - padding_count
Tail "QUE=" → data=3, padding=1 → output_len = 3-1 = 2 ✓
Tail "QQ==" → data=2, padding=2 → output_len = 2-2 = 0 ✓ (edge case)
For certain crafted inputs where the tail is very short with padding:
Tail with data=1, padding=2 → output_len = 1-2 = -1
Since the CPU uses **unsigned integer arithmetic**, `-1` wraps around:
Unsigned: 1 - 2 = 4,294,967,295 (0xFFFFFFFF)
This is a classic **integer underflow** (CWE-191).
The CPU uses the `BZHI` (Zero High Bits Starting with Specified Bit Position) instruction to create a write mask from `output_len`:
Normal: BZHI(mask, 2) → mask = 0b00000011 (write 2 bytes) ✓
Bug: BZHI(mask, 4294967295) → mask = 0b11111111...1111 (write ALL 64 bytes) ✗
When the bit index exceeds the register width (64), `BZHI` sets **all bits to 1**. The masked store then writes all 64 lanes instead of just the valid output bytes.
The output buffer was allocated for the expected (small) output size. The masked store writes 64 bytes into a buffer that may only hold 1-2 bytes:
[output buffer (2 bytes)][ object header][ object data][...]
|◄── valid ──►|◄──────── overflow: 62 bytes ────────────────►|
The 62 overflowed bytes corrupt whatever object sits adjacent
on the heap — object headers, pointers, metadata.
- ✅ Approximate heap position of the buffer (via heap grooming)
- ❌ Content of the overflowed bytes (determined by the decoder, not attacker)
┌─────────────────────────────────────────────────────────────────────┐
│ 1. Attacker sends crafted Base64 (>128 bytes + special padding) │
│ via HTTP header, JWT, API body, file upload, etc. │
└──────────────────────────┬──────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────┐
│ 2. Java application calls Base64.getDecoder().decode(input) │
│ This is a standard Java API call — nothing unusual │
└──────────────────────────┬──────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────┐
│ 3. If decode() has been called ~10,000+ times (C2 active), │
│ JVM uses AVX-512 intrinsic instead of Java code │
└──────────────────────────┬──────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────┐
│ 4. Tail padding handler: output_len = data - padding → UNDERFLOW │
│ BZHI creates all-ones mask → writes 64 bytes into small buffer │
└──────────────────────────┬──────────────────────────────────────────┘
| 1 | CPU with **AVX-512 VBMI** | Intel Ice Lake+, AMD Zen 4+. Most laptops lack this. Cloud VMs often have it |
| 2 | **Java 17.0.6+, 21, 25, or 27** | Java 8 and 11 have no Base64 intrinsic → not affected |
| 3 | App **decodes attacker-controlled Base64** | Must reach `Base64.getDecoder().decode()` with attacker input |
| 4 | **C2 JIT active** for Base64.decode() | Server must have been running long enough (~10,000 calls). Freshly started servers use interpreter/C1 |
| 5 | **Input > 128 bytes** | Shorter input uses scalar path, not AVX-512 |
| 6 | **Payload passes format validation** | Java checks Base64 format before intrinsic runs. Invalid format is rejected at Java layer |
| 7 | **Heap grooming** | Extremely hard over network. GC disrupts layout unpredictably |
| 8 | **ASLR bypass** | Need address leak to redirect execution |
| 9 | **WAF/middleware bypass** | Large Base64 payloads may be blocked by WAF, rate limiting, size limits |
| **DoS (crash)** | Moderate — need AVX-512 CPU + correct payload format | Server crash, service disruption |
| **RCE** | Very hard — need all above + heap grooming + ASLR bypass | Full server compromise |
| **Data leak** | Unlikely — attacker doesn't control overflow content | N/A |
**Real-world risk**: Most servers are safe because:
- Application doesn't expose direct Base64 decode from user input
- Java 8/11 (still widely used) are not affected
│ └── attack.sh Sends warmup + crafted payloads
├── victim :9091 (Spring Boot + Java 17, intrinsic ON)
│ ├── POST /decode — API accepts Base64 data
│ ├── POST /upload — File upload (Base64-encoded)
│ ├── GET /auth — HTTP Basic Auth header
│ └── GET /status — Health check
└── victim-safe :9092 (Same app, intrinsic OFF)
Two identical servers receiving the same payloads. If `victim` crashes but `victim-safe` survives → proves the bug is in the AVX-512 intrinsic.
- CPU with AVX-512 VBMI support (for actual crash trigger)
- Without AVX-512: lab still runs, demonstrates the concept, but won't crash
# Check JIT compilation levels (look for "level 4")
docker compose logs victim | grep "Base64"
curl -X POST \
curl -H "Authorization: Basic dXNlcjpwYXNz"
curl -X POST \
-d '{"filename": "test.txt", "content": "SGVsbG8gV29ybGQ="}'
# Compare: same request to safe server (port 9092)
The lab runs with `-XX:+PrintCompilation`. Look for compilation levels:
timestamp id level class::method (bytes)
643362 6974 3 java.util.Base64$Decoder::decode (120 bytes) ← C1 (safe)
703327 6894 4 java.util.Base64$Decoder::decode (120 bytes) ← C2 (vulnerable!)
- **Level 1-3** = C1 compiler → uses Java code → safe
- **Level 4** = C2 compiler → may use AVX-512 intrinsic → vulnerable
# Check Java version (17.0.6+ is affected)
# Check if Base64 intrinsic is enabled (default: yes)
java -XX:+PrintFlagsFinal -version 2>&1 | grep -i base64
java -XX:+PrintCompilation -jar your-app.jar 2>&1 | grep -i "base64.*decode"
- Unusually large Base64 payloads (>128 bytes) in headers or body
- Base64 strings with unusual padding patterns
- High volume of Base64 decode requests (warmup phase in lab scenarios)
| **1. Patch** | Apply Oracle November 2026 CPU / OpenJDK update (JDK-8393212) | Fixes the root cause |
| **2. Workaround** | Add JVM flag: `-XX:-UseBASE64Intrinsics` | Disables AVX-512 path, falls back to Java code. ~20x slower for Base64 |
| **3. Workaround** | Add JVM flag: `-XX:UseAVX=2` | Disables all AVX-512 instructions, uses AVX2 max |
| **4. WAF rule** | Limit Base64 input size in headers/body | Reduces attack surface |
| **5. Monitor** | Watch for JVM crashes (SIGSEGV) in Base64 decode paths | Early detection |
- [Wiz — CVE-2026-114938 Everything You Need to Know](
- [Horizon3.ai — Java Base64 Heap Overflow Technical Analysis](
- [Endor Labs — Pre-Auth Heap Overflow in OpenJDK](
- [Equixly — Pre-auth heap overflow in Java 17, 21, and 25](
- [HeroDevs — Exposure and How to Patch](
- [Cyber Kendra — Pre-Auth RCE Flaw in Java 17](
- [Harness — Past the End of the Buffer](
- [Sweet Security — Which Workloads Are at Risk](
- [Core Defences — Java4Shell Explained](
The full story
This article is one source in a clustered incident — the cluster page carries the summary, timeline and every other outlet covering it.
