Skip to content
Memory corruption Write-up Advanced

Java4Shell (CVE-2026–114938): Base64 Decoder Memory Corruption and Remote Code Execution [By…

A malformed Base64 input with a single trailing padding character causes the OpenJDK x86-64 Base64 decoder to compute a negative output size, leading to an out-of-bounds write of 62 bytes past the allocated array. An attacker could potentially exploit this memory corruption to achieve remote code execution, though the write is mostly fixed bytes and requires further exploitation steps.

Tharadol Suksamran Follow

Published on blog.snoopbees.com

Cybersecurity

Tharadol Suksamran, on blog.snoopbees.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 10 min read.

Context

Java4Shell (CVE-2026-114938) is a memory corruption vulnerability inside the OpenJDK HotSpot JVM, in the Base64 decoder path used on x86-64. Calif Research published the details on 17 November 2026. The affected component is the JVM's Base64 decoding intrinsic: on CPUs that support AVX-512 VBMI (Vector Byte Manipulation Instructions), OpenJDK replaces part of the Java Base64 decoder with hand-written machine code through the JVM Intrinsics mechanism, so that decoding runs faster than the pure Java implementation.

Normally this is invisible to the application. Base64.Decoder validates its input, allocates a destination array of the correct size, decodes into it, and throws IllegalArgumentException if the input is malformed. Java is a memory-safe language: the JVM manages memory and checks array bounds so that an application cannot read or write outside the memory it was given. Java4Shell breaks that expectation from inside the decoder itself.

https://calif.io/java4shell From the original on blog.snoopbees.com

The root of the problem is a miscalculation of the output byte count when the Base64 input ends in malformed padding. The result is an out-of-bounds write, which in turn can lead to remote code execution.

Affected and fixed Java versions From the original on blog.snoopbees.com

Setup

The proof of concept needs a machine that meets all of the following:

  • CPU x86-64
  • AVX-512 VBMI feature
  • a Java runtime at an affected version

Not every x86-64 machine has AVX-512 VBMI, so the first step is to check the CPU. The author notes that renting a VPS is the practical way to get one. The check is:

Bash
uname -mfor f in avx512f avx512bw avx512vbmi bmi2; do  grep -qm1 -w "$f" /proc/cpuinfo && echo "$f: OK" || echo "$f: MISSING"done

This prints the machine architecture and then, for each of avx512f, avx512bw, avx512vbmi and bmi2, either OK or MISSING depending on whether the flag appears in /proc/cpuinfo.

From the original on blog.snoopbees.com

Next, install Java. The author uses Temurin 21.0.13+9 because it is the release explicitly named for this vulnerability:

Bash
curl -fL --retry 3 \  'https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.13%2B9/OpenJDK21U-jdk_x64_linux_hotspot_21.0.13_9.tar.gz' \  -o /tmp/temurin-21.0.13+9.tar.gzmkdir -p /opt/java4shell/jdk21tar -xzf /tmp/temurin-21.0.13+9.tar.gz -C /opt/java4shell/jdk21 --strip-components=1

The curl call downloads the Temurin 21.0.13+9 Linux x64 archive with retries; the tar call unpacks it into /opt/java4shell/jdk21, stripping the top-level directory. Verify the installation with:

Bash
/opt/java4shell/jdk21/bin/java -version
From the original on blog.snoopbees.com

Finding it

The trigger input for recent affected OpenJDK releases is 64 A characters followed by a single =. The 64 A characters form 16 complete Base64 groups and decode to 48 bytes. The trailing = stands alone, which makes the input malformed. For affected OpenJDK 17 releases, 128 A characters before the = are needed to reach the vulnerable decode path.

What makes this interesting is the ordering of events. Java does detect that the Base64 input is invalid and throws IllegalArgumentException, but by the time it does so the memory inside the Java heap has already been corrupted.

From the original on blog.snoopbees.com

Exploitation

Step 1: reproduce the memory corruption

The author takes the Base64Trigger code from the Calif blog and runs it to compare results. If the output contains REPRODUCED, the memory corruption is real in that environment.

JavaScript
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");    }}

The program decodes the valid 64-character input into a 4096-byte target array 200,000 times, then fills target with 0x5a, calls decode with the malformed input, and records whether IllegalArgumentException was thrown. It then fills target with 0x5a, calls decode with the malformed input, and records whether IllegalArgumentException was thrown. Finally it scans target from index 50 onwards for bytes that are no longer 0x5a. The check requires the input to have been rejected, exactly 62 bytes changed, the first changed byte at index 50 and the last at index 111. Anything else prints NOT REPRODUCED and exits with status 1.

From the original on blog.snoopbees.com

With that, the memory corruption is proven to exist.

Step 2: understand what the corruption gives you

Reading the Calif blog, the author notes that Calif was able to extend the flaw to RCE against Keycloak, Jira, Confluence, Kafka, Elasticsearch and others.

https://www.youtube.com/watch?v=-EOYmL4UKvs From the original on blog.snoopbees.com

That looks dramatic: one run and you get a web shell? The answer is no. A single malformed Base64 request does not hand you a web shell. Base64Trigger only confirms that the decoder rejects the data after it has already written past the bounds of the array. That is the starting point of the vulnerability, not the end of it.

Calif published the exploitation strategy but not an exploit chain for each product. The reason given is that although every product starts from the same Base64 decoder, what sits around the output in memory, and what the application does with it afterwards, differs completely. No single PoC can be written once and exploited against every system.

Step 3: from memory corruption to RCE

From the original on blog.snoopbees.com

Imagine the decoder writing past its own array and into the data of an adjacent object. If that object is never used again, nothing visible happens, or the JVM simply crashes. If the damaged data is something the application still needs, such as an array length, the next read will believe there is more space than was actually allocated. That is where the impact shifts from "62 bytes written in the wrong place" to "reading data that should not be readable" or "writing to a location that should not be writable". Leaked data can reveal where things sit in the process, and if the write can be controlled further, it can reach parts of the JVM involved in execution and lead to code execution.

The first write in Java4Shell is limited: most of the bytes written out of bounds are not values the attacker chooses freely. Extending the bug therefore depends on object layout and on application behaviour. This is why Calif states that there is no single RCE payload for every Java service.

CPU and Java version alone are not enough either. The application itself must accept Base64 from outside and pass it through to the decoder, and it must have objects whose overwrite can be turned into something useful.

So Java4Shell does reach RCE, but only when several conditions hold together:

  1. The JVM is an affected version.
  2. The CPU and its configuration cause the JVM to use the vulnerable Base64 decoder.
  3. Base64 data from outside reaches the decoder, and the application's behaviour allows the result of the memory corruption to be used further.

Can it actually be done? Yes, but it is not the case that having Java installed means an immediate shell.

The lab PoC starts with a large number of normal Base64 decode operations (200,000) to push the JIT compiler into using the optimised, vulnerable Base64 decoder. It then sends malformed Base64 data to the server to trigger the memory corruption, then locates the JVM Code Cache and overwrites a function with prepared shellcode.

From the original on blog.snoopbees.com

Root cause

Before the fix, Base64.Decoder in OpenJDK allocates the result array and then calls the decode function:

JavaScript
byte[] dst = new byte[decodedOutLength(src, 0, src.length)];int ret = decode0(src, 0, src.length, dst);

For the 65-character input, decodedOutLength treats the trailing = as padding and computes an output size of 50 bytes using the formula 3 × ceil(65 / 4) − 1, where ceil rounds up. The array therefore has valid indices 0 to 49.

decode0 then passes the input and this array to decodeBlock, the path that has been optimised for speed. The first 64 A characters decode to 48 bytes and are written at indices 0 to 47. The next write position is index 48, which leaves only 2 bytes of room in the array.

The problem comes when the native decoder reaches the tail, where a single = remains. The output size for that part is computed as (1 / 4) × 3 − 1 = −1, because integer division counts no complete Base64 group but still subtracts 1 for padding.

The pre-fix routine on x86-64 looks like this:

JavaScript
__ decrementq(output_size, 1);__ shrq(rax, 1);__ movq(output_mask, -1);__ bzhiq(output_mask, output_mask, output_size);__ kmovql(k1, output_mask);__ evmovdqub(Address(dest, dp), k1, tmp, true, Assembler::AVX_512bit);

The first line subtracts 1 from the output size for the =, which makes output_size equal to −1 even though this tail has no data to decode. The following shift adjusts the mask used to read the input so that the = is excluded. The instruction that builds output_mask then sees the bad size: when bzhiq receives −1, all 64 bits of the mask stay set. kmovql moves that mask into k1, and evmovdqub writes to every position the mask allows. The result is a full 64-byte write.

The write starts at index 48 and ends at index 111. Indices 48 and 49 are still inside the 50-byte array, but indices 50 to 111 are 62 bytes written past the end. That is how a single malformed character in the tail causes a write of the full width of the vector.

Java then notices that the = is in the wrong position and throws the exception, but the write has already happened. A web service may therefore return an error while the memory inside the process has already been changed. Calif also notes that most of the out-of-bounds bytes are fairly fixed values: the attacker does not get to choose those 62 bytes as arbitrary code. Reaching RCE requires further steps that make use of the data or objects that were overwritten.

Impact

An attacker who can get malformed Base64 to a vulnerable decoder on a vulnerable CPU and JVM can corrupt memory in the Java process. Whether that becomes code execution depends on the application: the input must reach the decoder, and the overwritten objects must be usable in a way that advances the attack. Where those conditions are met, the corruption can be extended to run commands. Where they are not, the outcome may be nothing observable or a JVM crash. There is no universal payload, and the report does not give a CVSS score or a bounty.

Fix

OpenJDK fixed the issue by adding a length check before handling the tail:

JavaScript
__ cmpl(length, 4);__ jcc(Assembler::less, L_bruteForce);

In other words, if the tail is shorter than 4 characters, the decoder leaves the vulnerable vector path before the incorrect output mask is built.

For defenders, the report recommends:

  1. Update the Java runtime (JDK/JRE) to a version with the security patch for Java4Shell, or newer, checking the vendor's security advisory for the fixed versions.
  2. If updating is not possible, set the JVM argument -XX:-UseBASE64Intrinsics to disable Base64 hardware acceleration, or -XX:UseAVX=2 to disable AVX-512, which is a key condition for the attack.
  3. Limit the privileges of the Java process following least privilege, to reduce the impact of a successful RCE.

Variants to test

  • Other affected runtimes and versions. Run Base64Trigger against other JDKs and releases. A positive result is rejected=true changed=62 first=50 last=111 followed by REPRODUCED.
  • CPU feature combinations. Run the CPU check on candidate hosts and look for avx512vbmi: OK alongside the other flags.
  • Applications that decode external Base64. Look for services that accept Base64 from untrusted input and pass it to Base64.Decoder, such as authentication tokens, configuration blobs or message payloads.
  • JIT warm-up sensitivity. Vary the number of valid decode calls before sending the malformed input.
  • Mitigation verification. Re-run the trigger with -XX:-UseBASE64Intrinsics and with -XX:UseAVX=2.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 24 min read.

What happened, in plain words

In November 2026 a security research team called Calif Research published details of a bug in Java, the programming language and runtime that a very large number of web services, business applications and backend systems run on. The bug was given the name Java4Shell and the identifier CVE-2026-114938. A CVE is simply a public catalogue number for a known security flaw, so that everyone talking about it can be sure they mean the same thing.

The flaw is not in the Java code that a programmer writes. It is inside the Java Virtual Machine, usually shortened to JVM. The JVM is the program that actually runs Java code on a computer: it loads the code, manages the memory the code uses, and translates the code into instructions the processor understands. One of the jobs the JVM does for applications is decoding Base64, a way of packing binary data into ordinary text characters. On certain processors, the JVM has a special fast version of that decoder. The bug is in that fast version.

When the decoder is handed a particular kind of malformed Base64 text, it writes a small amount of data past the end of the memory area it was supposed to stay inside. Writing outside your own area is called an out-of-bounds write, and it belongs to a broad family of problems called memory corruption. In the worst case, memory corruption can be pushed further until an attacker can make the machine run commands of their choosing, which is called remote code execution, or RCE.

https://calif.io/java4shell From the original on blog.snoopbees.com

The important nuance, and the reason this article exists, is that this is not a case of "install Java, get hacked". Several conditions have to line up at once, and even then the first bad write is only a starting point. The rest of this article walks through the same material as the technical write-up, but explains every term from scratch.

Affected and fixed Java versions From the original on blog.snoopbees.com

Background: what Base64 is and why padding matters

Before the bug makes any sense, you need to know what Base64 actually does.

Computers store data as bytes, which are numbers between 0 and 255. Text, on the other hand, is made of characters. Some channels only carry text safely: email bodies, URLs, configuration files, JSON fields in a web request. Base64 is a scheme that takes arbitrary bytes and rewrites them using only 64 safe characters (the letters A to Z, a to z, the digits 0 to 9, plus + and /). It is not encryption and it hides nothing; anyone can reverse it. Its only purpose is to make binary data survive a trip through a text-only channel.

The encoding works in groups of three bytes. Every three bytes (24 bits) are chopped into four chunks of six bits, and each six-bit chunk is looked up in the table of 64 characters. So three bytes in become four characters out.

What happens when the input is not a multiple of three bytes? Then the last group is short, and the encoder fills the gap with the = character. That = is called padding. It is not data; it is a marker that says "the real content ended before this point".

From the original on blog.snoopbees.com

The article gives three small examples:

  • Man becomes TWFu (three bytes, four characters, no padding)
  • Ma becomes TWE= (two bytes, one padding character)
  • M becomes TQ== (one byte, two padding characters)

Why does this matter for a security bug? Because the decoder has to work out, before it starts, how much memory the decoded result will need. It does that by looking at the length of the text and at how many padding characters are at the end. If that arithmetic is wrong by even one, the decoder can reserve too little space and then write into memory that belongs to something else. In Java4Shell, the entire path to RCE begins with a single stray = character.

Background: memory, arrays and bounds checking

A computer's memory is a long row of numbered slots, each holding one byte. A program does not get the whole row; it gets regions handed to it, and it must stay inside them.

In Java, the most common container is an array: a fixed-size block of slots of the same type. When you write:

JavaScript
byte[] buffer = new byte[8];

you are asking the JVM for an array of eight bytes. The JVM finds eight free slots and gives you a handle to them. You can then use indices 0 through 7 to read or write each slot. Index 0 is the first slot, index 7 is the last. There is no index 8.

From the original on blog.snoopbees.com

If a program tries to touch index 8 anyway, the JVM stops it and throws an exception, which is Java's way of signalling an error. The specific exception here is ArrayIndexOutOfBoundsException. This automatic checking is called array bounds checking, and it is one of the main reasons Java is described as memory safe: a normal Java program simply cannot wander outside its own arrays, no matter how buggy the programmer's logic is.

That is exactly why this vulnerability is surprising. The check exists, the language is supposed to be safe, and yet the corruption still happens. The reason is that the fast Base64 decoder is not ordinary Java code. It is hand-written machine code that the JVM swaps in at runtime, and that machine code does its own arithmetic and its own memory writes without going through the usual checks.

From the original on blog.snoopbees.com

The sequence of events is the key detail: Java does notice that the Base64 input is invalid and does throw an exception. But the exception is thrown after the bad write has already landed in memory. From the application's point of view it looks like a clean rejection. From the memory's point of view, damage has been done.

Why a fast decoder exists at all

Modern processors have instruction sets: collections of operations the hardware can perform. Some of these are designed for doing many similar things at once, which is called SIMD, short for Single Instruction, Multiple Data. Instead of adding one pair of numbers per instruction, a SIMD instruction can add eight or sixteen pairs in one go.

AVX-512 is one such family of instructions on x86-64 processors (the processor family used in most servers and PCs). VBMI is a smaller extension within AVX-512 aimed at byte shuffling, which is precisely the kind of operation Base64 decoding needs. The full name is Vector Byte Manipulation Instructions.

Because Base64 decoding is so common (tokens, certificates, email attachments, API payloads), the JVM authors wrote a version of the decoder that uses these instructions directly. The mechanism that lets the JVM replace a Java method with a hand-optimised machine-code version is called a JVM intrinsic. It is a performance trick: same result, much faster.

The catch is that hand-written machine code does not get the safety net of the Java language. If its arithmetic is wrong, it will happily write wherever the arithmetic tells it to.

Root cause: the arithmetic that goes wrong

This is the heart of the bug, and it is worth following slowly.

Before the fix, the Java-level decoder did roughly this: work out how big the output will be, allocate an array of that size, then call the low-level decode routine to fill it.

JavaScript
byte[] dst = new byte[decodedOutLength(src, 0, src.length)];int ret = decode0(src, 0, src.length, dst);

Line by line:

  • byte[] dst = new byte[decodedOutLength(src, 0, src.length)]; asks a helper function, decodedOutLength, how many bytes the decoded result will occupy, given the input src from position 0 to the end. It then creates an array of exactly that many bytes and calls it dst, short for destination.
  • int ret = decode0(src, 0, src.length, dst); calls the actual decoding routine, passing the input, the range to read, and the destination array to write into. The return value is stored in ret.

The trigger input for recent affected OpenJDK releases is 64 A characters followed by one =. The 64 A characters form 16 complete Base64 groups and decode to 48 bytes of real data. The trailing = stands alone with nothing to pad, which makes the whole string malformed. For affected OpenJDK 17 releases, the same trick needs 128 A characters before the = in order to reach the vulnerable code path.

Now the arithmetic. The input is 65 characters long. The helper treats the final = as padding and applies the formula 3 × ceil(65 / 4) − 1, where ceil means round up. 65 divided by 4 is 16.25, rounded up is 17, times 3 is 51, minus 1 is 50. So the array is 50 bytes long, with valid indices 0 to 49.

The decoder then hands the input and this array to decodeBlock, the fast path. The first 64 A characters decode to 48 bytes and are written at indices 0 to 47. The next free position is index 48, which leaves exactly 2 bytes of room in the array.

Then the native decoder reaches the tail, where the lone = sits. It computes the output size for that tail as (1 / 4) × 3 − 1 = −1. The reason is integer division: 1 divided by 4 in whole numbers is 0, because there is not a single complete group of four characters. But the code still subtracts 1 for the padding character, and 0 minus 1 is −1.

A size of −1 is nonsense, and the machine code does not check for it. Here is the pre-fix routine on x86-64:

JavaScript
__ decrementq(output_size, 1);__ shrq(rax, 1);__ movq(output_mask, -1);__ bzhiq(output_mask, output_mask, output_size);__ kmovql(k1, output_mask);__ evmovdqub(Address(dest, dp), k1, tmp, true, Assembler::AVX_512bit);

Line by line:

  • __ decrementq(output_size, 1); subtracts 1 from the output size, accounting for the =. Since the size was already 0 for this tail, it becomes −1.
  • __ shrq(rax, 1); shifts a register right by one bit. This adjusts the mask used when reading the input, so that the = character is excluded from the data.
  • __ movq(output_mask, -1); sets a mask register to all ones, meaning "every bit is selected".
  • __ bzhiq(output_mask, output_mask, output_size); is meant to keep only the lowest output_size bits of the mask. With a sane size this would select exactly the bytes that should be written. With −1, the instruction leaves all 64 bits set.
  • __ kmovql(k1, output_mask); copies that mask into the register k1, which the vector instructions use to decide which bytes to touch.
  • __ evmovdqub(Address(dest, dp), k1, tmp, true, Assembler::AVX_512bit); performs the actual vector write: it stores bytes from tmp to the destination address, but only at the positions the mask in k1 allows. Because the mask is all ones, it writes all 64 bytes.

The write starts at index 48 and ends at index 111. Indices 48 and 49 are still inside the 50-byte array. Indices 50 through 111 are 62 bytes written past the end. That is how one malformed character at the tail causes a write the full width of the vector.

Java then notices that the = is in the wrong position and throws IllegalArgumentException. But the write has already happened. A web service may return an error to the caller while the memory inside its process has already been altered.

Calif also notes that most of the out-of-bounds bytes are fairly fixed values. The attacker does not get to choose those 62 bytes as arbitrary code. Getting from there to RCE requires further steps that make use of whatever data or objects were overwritten.

The fix

OpenJDK fixed the issue by adding a length check before handling the tail:

JavaScript
__ cmpl(length, 4);__ jcc(Assembler::less, L_bruteForce);

Line by line:

  • __ cmpl(length, 4); compares the length of the remaining tail with 4.
  • __ jcc(Assembler::less, L_bruteForce); is a conditional jump: if the comparison showed "less than", execution jumps to a slower, safe fallback routine labelled L_bruteForce.

In plain words: if the tail is shorter than four characters, the decoder leaves the vulnerable vector path before the incorrect output mask is ever built. A tail of one = can no longer reach the fast code.

Setting up a test machine

The proof of concept needs a machine that meets all of the following:

  • a CPU from the x86-64 family
  • the AVX-512 VBMI feature present on that CPU
  • a Java runtime at an affected version

Not every x86-64 machine has AVX-512 VBMI. Many consumer processors do not, and some cloud providers mask the feature off. The author notes that renting a VPS, a virtual private server, is the practical way to get a machine that has it. A VPS is simply a computer in a data centre that you rent by the hour or month and reach over the network.

The first step is to check the CPU:

Bash
uname -mfor f in avx512f avx512bw avx512vbmi bmi2; do  grep -qm1 -w "$f" /proc/cpuinfo && echo "$f: OK" || echo "$f: MISSING"done

Line by line:

  • uname -m prints the machine architecture, for example x86_64. This tells you whether you are even on the right family of processor.
  • for f in avx512f avx512bw avx512vbmi bmi2; do ... done is a loop that runs the same check once for each of four CPU feature names.
  • grep -qm1 -w "$f" /proc/cpuinfo searches the file /proc/cpuinfo, which on Linux lists the processor and its capabilities, for the current feature name. The -q makes it silent, -m1 stops at the first match, and -w requires a whole-word match so that a substring does not produce a false positive.
  • && echo "$f: OK" || echo "$f: MISSING" prints OK if the search succeeded and MISSING if it did not.
From the original on blog.snoopbees.com

Next, install Java. The author uses Temurin 21.0.13+9 because it is the release explicitly named for this vulnerability. Temurin is a freely redistributable build of OpenJDK produced by the Adoptium project, so it is the same underlying Java, packaged for easy download.

Bash
curl -fL --retry 3 \  'https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.13%2B9/OpenJDK21U-jdk_x64_linux_hotspot_21.0.13_9.tar.gz' \  -o /tmp/temurin-21.0.13+9.tar.gzmkdir -p /opt/java4shell/jdk21tar -xzf /tmp/temurin-21.0.13+9.tar.gz -C /opt/java4shell/jdk21 --strip-components=1

Line by line:

  • curl -fL --retry 3 '...' -o /tmp/temurin-21.0.13+9.tar.gz downloads the archive from GitHub. -f makes curl fail loudly on an HTTP error instead of saving an error page, -L follows redirects, --retry 3 tries again up to three times if the connection drops, and -o names the local file to save.
  • mkdir -p /opt/java4shell/jdk21 creates the directory where Java will live. -p means "create parents as needed and do not complain if it already exists".
  • tar -xzf /tmp/temurin-21.0.13+9.tar.gz -C /opt/java4shell/jdk21 --strip-components=1 unpacks the archive. -x extracts, -z handles gzip compression, -f names the file, -C chooses the destination directory, and --strip-components=1 drops the archive's top-level folder so the files land directly in the target directory.

Verify the installation with:

Bash
/opt/java4shell/jdk21/bin/java -version

This runs the freshly installed java binary with the -version flag, which prints the version and exits. It is the quickest way to confirm that the download unpacked correctly and that you are about to test the version you think you are testing.

From the original on blog.snoopbees.com

Step 1: reproduce the memory corruption

The author takes the Base64Trigger program from the Calif blog and runs it to compare results. If the output contains REPRODUCED, the memory corruption is real in that environment.

JavaScript
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");    }}

Line by line:

  • The three import lines bring in helper classes: StandardCharsets for turning text into bytes with a named character set, Arrays for filling an array with a value, and Base64 for the decoder itself.
  • public final class Base64Trigger { declares the program. final just means nothing can extend it.
  • private static volatile int sink; declares a variable that the program adds results into. volatile stops the compiler from optimising the loop away entirely, which matters because the loop exists for its side effect on the JVM, not for its return value.
  • Base64.Decoder decoder = Base64.getDecoder(); obtains the standard Base64 decoder object.
  • byte[] valid = "A".repeat(64).getBytes(StandardCharsets.US_ASCII); builds the well-formed input: 64 A characters, converted to bytes.
  • byte[] malformed = ("A".repeat(64) + "=").getBytes(StandardCharsets.US_ASCII); builds the malformed input: the same 64 A characters with one = appended.
  • byte[] target = new byte[4096]; creates the destination array. It is deliberately much larger than needed, so that the program can later look at the region just past the 50 bytes the decoder thinks it is using.
  • for (int i = 0; i < 200_000; i++) { sink += decoder.decode(valid, target); } decodes the valid input 200,000 times. This repetition is the point: it warms up the JVM's just-in-time compiler, usually shortened to JIT. The JIT watches which code runs hot and replaces it with faster compiled versions, and that is what causes the optimised Base64 decoder, the one containing the flaw, to be selected.
  • Arrays.fill(target, (byte) 0x5a); fills the whole array with the byte value 0x5a, which is the letter Z. This is a canary: any byte that later differs from 0x5a was changed by something else.
  • boolean rejected = false; prepares a flag to record whether the malformed input was refused.
  • try { decoder.decode(malformed, target); } catch (IllegalArgumentException expected) { rejected = true; } sends the malformed input to the decoder. The decoder is expected to throw IllegalArgumentException; the catch block records that this happened. The word expected in the catch is a reminder that this exception is the normal, correct behaviour, not a failure of the test.
  • int changed = 0; int first = -1; int last = -1; set up counters for the scan that follows.
  • for (int i = 50; i < target.length; i++) { ... } walks the array from index 50 onwards. Index 50 is the first position that should be outside the 50-byte region the decoder was allowed to use.
  • if (target[i] != (byte) 0x5a) { changed++; if (first < 0) first = i; last = i; } counts every byte that is no longer Z, remembers the first such index and keeps updating the last.
  • The three System.out.println and System.out.printf lines print the Java runtime version, the JVM name, and the results: whether the input was rejected, how many bytes changed, and where the first and last changes were.
  • if (!rejected || changed != 62 || first != 50 || last != 111) { System.err.println("NOT REPRODUCED"); System.exit(1); } is the pass/fail test. The input must have been rejected, exactly 62 bytes must have changed, the first change must be at index 50 and the last at index 111. Anything else prints NOT REPRODUCED and exits with status 1.
  • System.out.println("REPRODUCED"); prints the success marker.
From the original on blog.snoopbees.com

With that, the memory corruption is proven to exist on that machine.

Step 2: understand what the corruption actually gives you

Reading the Calif blog, the author notes that Calif was able to extend the flaw to RCE against Keycloak, Jira, Confluence, Kafka, Elasticsearch and others. Those are all well-known server products: Keycloak handles login and identity, Jira and Confluence are Atlassian's issue tracker and wiki, Kafka is a message queue, Elasticsearch is a search engine. They are named as products Calif was able to extend the flaw to RCE against.

https://www.youtube.com/watch?v=-EOYmL4UKvs From the original on blog.snoopbees.com

That looks dramatic: one run and you get a web shell? A web shell is a small piece of code an attacker plants on a server so they can send it commands through the browser and get the output back. The answer is no. A single malformed Base64 request does not hand you a web shell. Base64Trigger only confirms that the decoder rejects the data after it has already written past the bounds of the array. That is the starting point of the vulnerability, not the end of it.

Calif published the exploitation strategy but not an exploit chain for each product. An exploit chain is the sequence of steps that turns a small primitive, here "62 bytes written in the wrong place", into something useful like command execution. The reason given is that although every product starts from the same Base64 decoder, what sits around the output in memory, and what the application does with it afterwards, differs completely. No single PoC can be written once and exploited against every system.

Step 3: from memory corruption to RCE

From the original on blog.snoopbees.com

Imagine the decoder writing past its own array and into the data of an adjacent object. An object here means any structured piece of data the program keeps in memory: another array, a string, a record describing a user session. If that object is never used again, nothing visible happens, or the JVM simply crashes. If the damaged data is something the application still needs, such as an array length, the next read will believe there is more space than was actually allocated. That is where the impact shifts from "62 bytes written in the wrong place" to "reading data that should not be readable" or "writing to a location that should not be writable". Leaked data can reveal where things sit in the process, and if the write can be controlled further, it can reach parts of the JVM involved in execution and lead to code execution.

The first write in Java4Shell is limited: most of the bytes written out of bounds are not values the attacker chooses freely. Extending the bug therefore depends on object layout, meaning the order and spacing in which the application's data happens to sit in memory, and on application behaviour. This is why Calif states that there is no single RCE payload for every Java service.

CPU and Java version alone are not enough either. The application itself must accept Base64 from outside and pass it through to the decoder, and it must have objects whose overwrite can be turned into something useful.

So Java4Shell does reach RCE, but only when several conditions hold together:

  1. The JVM is an affected version.
  2. The CPU and its configuration cause the JVM to use the vulnerable Base64 decoder.
  3. Base64 data from outside reaches the decoder, and the application's behaviour allows the result of the memory corruption to be used further.

Can it actually be done? Yes, but it is not the case that having Java installed means an immediate shell.

The lab PoC starts with a large number of normal Base64 decode operations (200,000) to push the JIT compiler into using the optimised, vulnerable Base64 decoder. It then sends malformed Base64 data to the server to trigger the memory corruption, then locates the JVM Code Cache and overwrites a function with prepared shellcode. The Code Cache is the region of memory where the JIT keeps the machine code it has generated; shellcode is a small piece of machine code whose only job is to start a shell or run a command.

From the original on blog.snoopbees.com

Impact

An attacker who can get malformed Base64 to a vulnerable decoder on a vulnerable CPU and JVM can corrupt memory in the Java process. Whether that becomes code execution depends on the application: the input must reach the decoder, and the overwritten objects must be usable in a way that advances the attack. Where those conditions are met, the corruption can be extended to run commands. Where they are not, the outcome may be nothing observable or a JVM crash. There is no universal payload, and the report does not give a CVSS score or a bounty.

Mitigations

For defenders, the report recommends:

  1. Update the Java runtime (JDK/JRE) to a version with the security patch for Java4Shell, or newer, checking the vendor's security advisory for the fixed versions. JDK and JRE are the two packaging names for Java: the JRE is the runtime that executes programs, the JDK adds the tools needed to build them.
  2. If updating is not possible, set the JVM argument -XX:-UseBASE64Intrinsics to disable Base64 hardware acceleration, or -XX:UseAVX=2 to disable AVX-512, which is a key condition for the attack. A JVM argument is a startup option passed on the command line that changes how the JVM behaves.
  3. Limit the privileges of the Java process following least privilege, to reduce the impact of a successful RCE. Least privilege means giving a process only the access it genuinely needs, so that if it is taken over, the attacker inherits very little.

Variants to test

  • Other affected runtimes and versions. Run Base64Trigger against other JDKs and releases. A positive result is rejected=true changed=62 first=50 last=111 followed by REPRODUCED.
  • CPU feature combinations. Run the CPU check on candidate hosts and look for avx512vbmi: OK alongside the other flags. A negative control is a test you expect to fail, run to prove that your test can actually tell the difference.
  • Applications that decode external Base64. Look for services that accept Base64 from untrusted input and pass it to Base64.Decoder, such as authentication tokens, configuration blobs or message payloads. A token here is a string a server issues to a client to prove identity on later requests.
  • JIT warm-up sensitivity. Vary the number of valid decode calls before sending the malformed input.
  • Mitigation verification. Re-run the trigger with -XX:-UseBASE64Intrinsics and with -XX:UseAVX=2.

Conclusion

In 2026 we keep seeing vulnerability names ending in "2Shell" or "4Shell". The word Shell makes people picture a single payload that returns a shell, and worry that every system using that technology is equally exposed. Reality is usually less direct. In Java4Shell the starting point is a Base64 decoder writing past the space it reserved; reaching RCE takes several further steps.

That said, Java4Shell is not a purely theoretical risk. If the conditions line up, the first memory corruption can be extended until commands run. The name does not mean every machine running Java can be taken over in the same way.

In practice, if your system matches the affected profile, update the Java runtime you actually run to a fixed release, to prevent the damage that could otherwise follow.

Glossary

  • API: a defined way for one program to talk to another, like a menu of requests a service accepts and the answers it gives.
  • Array: a fixed-size block of numbered memory slots holding values of the same type.
  • Array bounds checking: the JVM's automatic check that a program only touches indices inside an array.
  • AVX-512: a family of processor instructions that operate on many bytes at once.
  • AVX-512 VBMI: a part of AVX-512 aimed at byte shuffling, used by the fast Base64 decoder.
  • Base64: an encoding that turns arbitrary bytes into 64 safe text characters, used to carry binary data through text channels.
  • Base64 decoder: the routine that turns Base64 text back into the original bytes.
  • Byte: a number from 0 to 255, the basic unit of computer memory.
  • Code Cache: the memory region where the JIT stores the machine code it generates.
  • CPU: the processor, the chip that executes instructions.
  • CVE: a public catalogue number for a known security vulnerability.
  • CVSS: a scoring system for rating the severity of a vulnerability.
  • Destination buffer: the memory area a decoder writes its output into.
  • Exception: Java's way of signalling that something went wrong, which can be caught and handled.
  • Exploit chain: the sequence of steps that turns a small bug into a full attack.
  • IllegalArgumentException: the exception Java throws when a method is given an argument it considers invalid.
  • Intrinsic: a Java method that the JVM replaces with hand-written machine code for speed.
  • JDK: the Java Development Kit, the runtime plus the tools needed to build Java programs.
  • JIT compiler: the part of the JVM that turns frequently used code into fast machine code while the program runs.
  • JRE: the Java Runtime Environment, the part of Java that runs programs.
  • JVM: the Java Virtual Machine, the program that runs Java code and manages its memory.
  • Least privilege: the principle of giving a process only the access it genuinely needs.
  • Machine code: the raw instructions a processor executes.
  • Mask: a pattern of bits used to select which bytes an instruction should touch.
  • Memory corruption: damage to memory caused by a program writing where it should not.
  • Memory safe: a language or runtime that prevents programs from reading or writing outside their own memory.
  • Object: a structured piece of data a program keeps in memory.
  • OpenJDK: the open-source reference implementation of Java.
  • Out-of-bounds write: writing data past the end of the memory area a program was given.
  • Padding: the = characters at the end of Base64 text that mark where the real data stops.
  • PoC: proof of concept, a small program or request that demonstrates a vulnerability exists.
  • Remote code execution (RCE): making a remote machine run commands of the attacker's choosing.
  • Shellcode: a small piece of machine code whose job is to start a shell or run a command.
  • SIMD: a processor capability to perform one operation on many pieces of data at once.
  • Temurin: a freely redistributable build of OpenJDK produced by the Adoptium project.
  • Token: a string a server issues to a client to prove identity on later requests.
  • Vector: a processor register that holds several values at once.
  • VPS: a virtual private server, a rented machine in a data centre reached over the network.
  • Web shell: a small piece of code planted on a server so an attacker can send it commands through the browser.
  • x86-64: the processor family used in most servers and PCs.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.