MathanKumar Stalin
MathanKumar Stalin

Solution Engineer

System Engineer

DevOps Engineer

Ethical Hacker

Cyber Security

MathanKumar Stalin

Solution Engineer

System Engineer

DevOps Engineer

Ethical Hacker

Cyber Security

Java4Shell (CVE-2026-114938): How 65 Bytes of Base64 Broke Java’s Memory Safety

November 19, 2026 AI, Cybersecurity

If someone told you there’s a critical remote memory-corruption bug sitting inside Java’s Base64 decoder, your first reaction would probably be, “Wait—isn’t memory safety the entire point of running on the JVM?”

Yeah, mine too.

On November 17, 2026, researchers at Calif disclosed Java4Shell (CVE-2026-114938)—a heap buffer overflow in OpenJDK that scores 9.2 Critical under CVSS 4.0 (Oracle rates it 8.1 under CVSS 3.1). With zero credentials, an attacker can corrupt Java heap memory, leak sensitive data straight out of RAM (Heartbleed-style, which they dubbed JavaBleed), and escalate all the way to Remote Code Execution (RCE).

Here’s what is actually happening under the hood, how to check if your Linux boxes are even vulnerable, and how to kill the risk in five minutes if you can’t patch today.

Wait, How Do You Get Memory Corruption in Java?

Your Java code is memory-safe. The JVM running it is not.

HotSpot is built on C, C++, and hand-rolled assembly. When a method gets called repeatedly, the C2 JIT compiler compiles it down to native machine code. For hot operations like Base64 decoding, HotSpot goes a step further and swaps in CPU-specific intrinsics—custom assembly routines that use modern SIMD instructions to chew through data faster .

That’s where the bug lives: inside OpenJDK HotSpot’s x86-64 AVX-512 Base64 intrinsic.

When the decoder processes the final partial block (less than 64 bytes) of a Base64 string, it calculates how many bytes to write back to memory and builds a 64-bit write mask using the BZHI instruction . The logic looks roughly like this:

output_len = (input_length / 4) * 3
// subtract 1 for each '=' padding byte at the end
output_mask = bzhiq(-1, output_len)

Now watch what happens if you feed it 64 A characters followed by a single = (or 128 As + = on older OpenJDK 17 builds):

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
  1. OpenJDK allocates a 50-byte output buffer.
  2. The intrinsic decodes the first 64 bytes into offsets 0..47.
  3. It hits the stray = at the end. Because the remaining chunk is 1 byte, (1 / 4) * 3 evaluates to 0.
  4. Then it subtracts 1 for the = padding character. output_len underflows to -1.
  5. Passing a negative number (treated as a huge unsigned integer) into bzhiq sets all 64 bits of the write mask to 1.
  6. The AVX-512 store instruction (VMOVDQU8 / evmovdqub) fires and blasts 64 bytes starting at offset 48

Two bytes land inside the buffer. The other 62 bytes spill straight out of bounds into whatever Java object happens to be sitting next door on the heap.

Java does realize the Base64 string is invalid and throws an IllegalArgumentException—but by the time that exception fires, the memory overwrite has already happened.

Turning a 62-Byte Spill Into RCE

Normally, a fixed-value out-of-bounds write is a pain to weaponize. You don’t control the spilled bytes, only where they land.

Calif got around this using classic browser/JIT exploitation primitives adapted for the G1 garbage collector:

Warm up the JIT: Send normal Base64 requests until C2 compiles the decode path into the vulnerable AVX-512 intrinsic.

Remote Heap Feng Shui: Force critical arrays out of thread-local allocation buffers (TLABs) into G1 regions and spray pairs of target arrays (“writers” and “readers”) by controlling HTTP request timing and TCP packet boundaries.

Corrupt a Length Field: Trigger the 62-byte spill to overwrite the length of a neighboring writer array. Now you have a controlled linear write.

JavaBleed (Heap Leak): Use that writer to inflate the length of a reader array whose contents get echoed back in an HTTP response. Suddenly you’re dumping live heap memory—JWTs, session tokens, private keys, whatever is in RAM.

Repair & Execute: Patch up any trashed headers so the JVM doesn’t segfault, then escalate to arbitrary writes targeting JVM hooks and the Code Cache.

The good news: This is not a point-and-shoot universal exploit like Log4Shell. Every target app needs its own custom heap layout and feedback profile. Default request buffering in reverse proxies like Nginx can also break streaming-based heap grooming (though single-request targets like Elasticsearch or WebSocket tunnels bypass that).

The bad news: Calif already proved pre-auth RCE on default configs of Keycloak, Jira, Confluence, Jenkins, JFrog Artifactory, and PingFederate, plus post-auth RCE on Kafka Broker, Elasticsearch, Solr, Gerrit, and Spinnaker. Because Base64 shows up everywhere—HTTP Basic Auth headers, JWTs, SAML, file uploads—this hits way before authentication in a lot of stacks. There’s even a client-side variant where a Java app connecting to a malicious TLS server can get popped.

Are Your Servers Actually Vulnerable?

You are only exposed if all of these are true:

  • Java Version: Running OpenJDK 17.0.6 or newer (this includes Corretto, Temurin, Zulu, Liberica, Red Hat OpenJDK, Microsoft Build of OpenJDK, Oracle Java SE, and GraalVM). Standard Java 8, Java 11, and OpenJ9 don’t have this stub. (Note: Oracle’s 8u511b33-perf build is an exception and is affected.)
  • CPU Architecture: x86-64 with AVX-512 VBMI. That means Intel Xeon Ice Lake or newer (Sapphire/Emerald/Granite Rapids) or AMD EPYC/Ryzen Zen 4+. ARM64 (AWS Graviton, Apple Silicon) is completely unaffected.
  • Attack Surface: Your app passes untrusted Base64 data into java.util.Base64.Decoder.

Run this on your Linux hosts to see if the CPU even supports the vulnerable instructions:

grep -m1 '^flags' /proc/cpuinfo | tr ' ' '\n' | grep -E '^(avx512f|avx512bw|avx512vbmi|bmi2)$'

If all four flags (avx512f, avx512bw, avx512vbmi, bmi2) show up, your hardware is in scope.

One trap to watch out for: Don’t just run java -version on the host OS and call it a day. Check every Docker container, Kubernetes pod, and vendor appliance that bundles its own JDK—OS package updates won’t touch those. Also, if a workload isn’t vulnerable today because it’s on an older CPU, a cloud instance resize or K8s node reschedule onto newer silicon can make it vulnerable overnight.

How to Fix or Mitigate It Right Now

1. Patch the JVM (Best Fix)

Oracle and OpenJDK vendors dropped patches on November 17, 2026. Upgrade all supported LTS/current lines (17, 21, 25, 27). If you’re still running EOL branches like Java 18–20, 22–24, or 26, there are no patches coming—time to migrate.

2. Kill the Intrinsic with a JVM Flag (Instant Workaround)

If you can’t roll a full JDK upgrade tonight, add one of these flags to your JVM startup options and restart the service:

# Option A: Disable only the Base64 hardware intrinsic
-XX:-UseBASE64Intrinsics

# (On some OpenJDK builds, pair it with -XX:+UnlockDiagnosticVMOptions)

Or disable AVX-512 entirely:

# Option B: Cap AVX to AVX2 (x86-64 ONLY!)
-XX:UseAVX=2

Warning: Do not blindly push -XX:UseAVX=2 to mixed fleets or ARM64 nodes—ARM JVMs don’t recognize the flag and will refuse to start.

3. Hunt in Your Logs / WAF

If you log Base64 headers or tokens at your reverse proxy or WAF, flag any Base64 string where:

  • Total length L is 65 or more
  • L % 64 is 1, 2, or 3
  • It ends with one or two = characters

Testing It Safely: Standalone PoC & Docker Audit Script

If you don’t want to guess based on version strings alone, you can verify the bug directly—safely—and sweep your running containers in under a minute.

1. Safe Standalone Java PoC

Calif published a bounded trigger that proves whether your JVM hits the bug without crashing the process. It warms up the C2 JIT compiler, fills a 4,096-byte buffer with 0x5a, and feeds the malformed 65-byte Base64 string into Base64.Decoder. Because the target array is oversized, the 62-byte spill lands safely inside the allocated array instead of corrupting neighboring heap objects.

Save this as Base64Trigger.java:

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

/** Bounded standalone trigger: every write stays inside a real 4096-byte array. */
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];

        // Warm up the JIT so C2 compiles the AVX-512 Base64 intrinsic
        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 it:

javac Base64Trigger.java
java Base64Trigger

On a vulnerable JDK + AVX-512 host, you’ll see rejected=true changed=62 first=50 last=111 followed by REPRODUCED.

(Note: If you’re testing an older OpenJDK 17 build, bump the "A".repeat(64) lines to "A".repeat(128) and adjust the loop start offset from 50 to 98—JDK 17 has a higher length threshold before entering the intrinsic.)

Now test the mitigation right on the same box:

java -XX:-UseBASE64Intrinsics Base64Trigger

It should immediately flip to changed=0 and NOT REPRODUCED.

2. Quick Bash Script to Audit Running Docker Containers

Since containers share the host CPU, checking Docker fleets is a two-step deal: verify the host CPU flags once, then loop through every running container to find bundled JVMs that OS patching won’t touch.

Save this as audit-java4shell.sh and run it with bash audit-java4shell.sh:

#!/usr/bin/env bash
set -euo pipefail

echo "=== 1. Checking Host CPU Flags ==="
REQUIRED_FLAGS=("avx512f" "avx512bw" "avx512vbmi" "bmi2")
CPU_FLAGS=$(grep -m1 '^flags' /proc/cpuinfo || true)
MISSING=0

for flag in "${REQUIRED_FLAGS[@]}"; do
    if ! grep -qw "$flag" <<< "$CPU_FLAGS"; then
        MISSING=1
    fi
done

if [[ "$MISSING" -eq 0 ]]; then
    echo "[!] Host CPU supports AVX-512 VBMI (Hardware is IN SCOPE)"
else
    echo "[OK] Host CPU lacks required AVX-512 VBMI flags (Safe on this host, but still patch before migrating nodes)"
fi

echo ""
echo "=== 2. Scanning Running Docker Containers ==="
printf "%-25s %-30s %-20s %s\n" "CONTAINER" "IMAGE" "JAVA_VERSION" "STATUS"
printf "%-25s %-30s %-20s %s\n" "---------" "-----" "------------" "------"

docker ps --format '{{.ID}} {{.Names}} {{.Image}}' | while read -r cid name image; do
    # Try standard PATH first, then common bundled JDK paths
    jver=$(docker exec "$cid" sh -c '
        JAVA_BIN=$(command -v java || find /opt /usr/lib/jvm /app -maxdepth 4 -type f -name java 2>/dev/null | head -n1)
        [ -n "$JAVA_BIN" ] && "$JAVA_BIN" -version 2>&1 | head -n1
    ' 2>/dev/null || true)

    if [[ -z "$jver" ]]; then
        continue
    fi

    # Extract version number (e.g., 17.0.10, 21.0.2, 1.8.0_402)
    ver_num=$(echo "$jver" | sed -n 's/.*"\([^"]*\)".*/\1/p')
    major=$(echo "$ver_num" | cut -d. -f1)

    status="CHECK MANUALLY"
    if [[ "$major" == "1" || "$major" == "11" ]]; then
        status="LIKELY SAFE (Pre-17)"
    elif [[ "$major" =~ ^[0-9]+$ ]] && (( major >= 17 )); then
        # Check if mitigation flag is already active on the Java process
        flags=$(docker exec "$cid" sh -c 'tr "\0" " " < /proc/1/cmdline 2>/dev/null || ps aux 2>/dev/null' 2>/dev/null || true)
        if grep -qE '(-XX:-UseBASE64Intrinsics|-XX:UseAVX=2)' <<< "$flags"; then
            status="MITIGATED (Flag Set)"
        else
            status="CHECK / PATCH (>=17)"
        fi
    fi

    printf "%-25.25s %-30.30s %-20.20s %s\n" "$name" "$image" "${ver_num:-unknown}" "$status"
done

A quick heads-up on edge cases: distroless containers (which don’t ship /bin/sh) won’t respond to docker exec ... sh. For those, inspect the image metadata directly with docker inspect or scan the image SBOM using Trivy/Syft so nothing slips through the cracks.

Final Thought

The wildest part of Calif’s write-up isn’t even the assembly bug—it’s how they found it. One researcher paired with an AI coding agent found the flaw in an hour and built the first working exploit in two more hours, spending less than $200 in tokens.

It’s a solid reminder that “memory-safe” runtimes still carry massive amounts of low-level C and assembly optimizations under the hood. Most web apps decoding a 100-byte Basic Auth header never needed hand-rolled AVX-512 assembly to shave off a few nanoseconds—yet everyone inherited the attack surface anyway.

Check your containers, drop the flag if you have to, and get those JVMs patched.

Related Posts
Write a comment