Skip to content
Memory corruption Write-up Advanced

Java4Shell (CVE-2026–114938): When Java’s Base64 Decoder Forgot How Memory Works

A memory-corruption flaw in Java's accelerated Base64 decoder causes an out-of-bounds write when processing certain malformed padding. An attacker who can supply input to the decoder could corrupt heap memory, potentially leading to code execution.

Shah kaif Follow

Published on infosecwriteups.com

Java4shell

Shah kaif, on infosecwriteups.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. 6 min read.

Context

Java4Shell (CVE-2026-114938) is a memory-corruption vulnerability in the accelerated Base64 decoder of affected JDK builds. The feature in question is the intrinsic that replaces the ordinary Java implementation of Base64.getDecoder(), getUrlDecoder() and getMimeDecoder() with hand-written native/assembly code. That intrinsic processes input in large chunks using AVX-512 instructions rather than one character at a time.

The bug appears in how the decoder calculates the write mask near the end of the input when padding (=) is involved. Certain malformed padding triggers an integer underflow in that calculation, and instead of a mask sized for the correct number of output bytes the routine produces an all-ones mask. The decoder then writes 64 bytes into a buffer that usually has no room for them, producing an out-of-bounds write into adjacent heap memory.

The JVM does eventually throw an IllegalArgumentException, but only after the write has happened. The rejection is real, and so is the corruption.

From the original on infosecwriteups.com

The author's framing is that Java developers trust the JVM to handle memory safely, and this bug shows that a memory-managed language can inherit memory-corruption problems from the low-level code underneath it. The precise byte-offset arithmetic is deliberately left out of this write-up and attributed to Calif's original research.

Setup

This is a research write-up rather than a test against a live target, so there are no accounts or roles. The relevant preconditions are the four conditions the author says must all line up for the bug to be exploitable:

  1. Unpatched OpenJDK 17.0.6+ (or an affected Oracle/GraalVM build listed below).
  2. An x86-64 CPU with AVX-512 VBMI, specifically AVX512F, AVX512BW, AVX512VBMI and BMI2. AVX2 does not count, and ARM64 hosts are not affected.
  3. The accelerated decoder actually enabled, not turned off via -XX:-UseBASE64Intrinsics or -XX:UseAVX=2.
  4. Attacker-controlled input reaching Base64.getDecoder(), for example Basic Auth headers, SAML, file uploads, REST/GraphQL parameters or CSRF tokens.

Affected and patched builds, as given in the report:

Text
Product                                  Vulnerable Build       Patched BuildOracle Java SE 17                        17.0.21.0.3             17.0.21.1Oracle Java SE 21                        21.0.13.0.3             21.0.13.1Oracle Java SE 25                        25.0.5.0.3              25.0.5.1Oracle Java SE 27                        27.0.1.0.3             27.0.1.1Oracle Java 8 Enterprise Perf Pack       8u511b33-perf           Nov 17 2026 updateOracle GraalVM for JDK 17                17.0.21.0.3             Nov 17 2026 updateOracle GraalVM for JDK 21                21.0.13.0.3             Nov 17 2026 updateOracle GraalVM Enterprise Edition        21.3.20.0.3             Nov 17 2026 updateNOT AFFECTED: Standard Oracle Java SE 8 and 11 builds (per Red Hat advisory)

Standard Oracle Java SE 8 and 11 builds are not affected, per the Red Hat advisory. The report advises verifying affected builds against the vendor advisory before acting.

Finding it

The premise is that a Base64 decoding operation, which developers treat as harmless, can overwrite memory outside its allocated array. The accelerated decoder handles input in large chunks, and the mask calculation near the end of the input is where the padding handling goes wrong. Malformed padding causes an integer underflow, the mask becomes all-ones, and the routine writes 64 bytes regardless of how much room is left in the output buffer.

The reason Java's memory safety does not help is that the optimized intrinsic is hand-written native/assembly code sitting underneath Java's safety net, not inside it. Java protects application code; it never promised the plumbing underneath was leak-proof.

Exploitation

The report describes the exploitation chain at a high level and explicitly paraphrases Calif's research rather than reproducing it. The steps below follow that description.

Step 1: Trigger the out-of-bounds write

Attacker-controlled input containing malformed padding reaches Base64.getDecoder(). The accelerated decoder computes an all-ones write mask and writes 64 bytes past the end of the output buffer. The JVM then throws IllegalArgumentException, but the write has already occurred.

Step 2: Heap grooming

The initial corruption gives limited, clumsy control. Heap grooming is used to nudge useful objects closer to the damaged buffer, in the author's analogy rearranging furniture before a guest you do not trust shows up.

Step 3: Upgrade to a general write primitive

Manipulating array metadata turns the limited corruption into a more general write primitive.

Step 4: Read memory

With the write primitive in place, the chain opens the door to reading memory, including tokens, keys and secrets. Calif compares this part to Heartbleed.

Step 5: Reach code execution

With enough of these primitives stacked up, application-specific exploitation can eventually reach code execution. The author stresses that there is no one-size-fits-all exploit: every application's memory layout is different, so weaponizing this against a specific target is custom work, not copy-paste.

Root cause

The mistake is in the accelerated decoder's mask calculation near the end of input. When padding is involved, certain malformed padding causes an integer underflow, and the resulting mask is all-ones instead of being sized for the correct number of output bytes. The routine then writes 64 bytes without checking whether the output buffer has room for them.

Existing defences did not stop it because the intrinsic is native/assembly code beneath the JVM's memory-safety guarantees. The exception thrown afterwards does not undo the write.

Impact

An attacker who can reach a vulnerable decoder with controlled input can corrupt heap memory. The report describes the chain as leading, with enough work, to memory disclosure (tokens, keys, secrets) and eventually code execution, but it hedges: the initial corruption is limited and clumsy, exploitation is application-specific, and the report does not claim a working end-to-end exploit against any named application.

Applications discussed in the research are described as plausibly exposed, not guaranteed pwned:

  • Pre-auth: Keycloak, Jenkins, Jira, Confluence, Artifactory, PingFederate.
  • Post-auth: Kafka Broker, Solr, Elasticsearch, Gerrit, Spinnaker.

Desktop and client applications are not exempt. A Java client that opens a TLS connection to a malicious server can have corrupted data pushed back at it, so being the one who initiates the connection does not make it safe from what comes back.

Exposure depends on all four preconditions being met at once: an affected build, a CPU with the required AVX-512 features, the intrinsic enabled, and attacker-controlled input reaching the decoder.

Fix

Patch to the vendor-fixed build listed in the table and check the full build number, since installing "Java 17" is not the same as installing the patched Java 17.

If patching is not possible immediately, the report gives these flags to buy time:

-XX:-UseBASE64Intrinsics   -XX:UseAVX=2

Beyond patching, the report recommends inventorying every bundled JVM hiding in containers, rebuilding images after patching rather than only patching the host, restarting processes after flag changes (a flag that is not loaded has no effect), and checking authentication and upload endpoints first.

Variants to test

These are concrete checks to run on other Java deployments, each with what a positive result looks like.

  1. Identify the JVM actually running the application. The default java -version can be misleading, so query the running process directly:

    java -versionjcmd -ljcmd PID VM.version
    

    A positive result is a build matching one of the vulnerable builds in the table, rather than the patched build.

  2. Check CPU flags on Linux. All four features must be present:

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

    A positive result is all four flags printed. On cloud instances, run this from inside the guest, because the hypervisor decides what the VM sees, not the provider's marketing page.

  3. Trace the code paths. Search for the decoder entry points:

    Base64.getDecoder() / getUrlDecoder() / getMimeDecoder()
    

    Finding one proves nothing by itself. A positive result is following the data and confirming that something an attacker controls actually reaches the decoder.

  4. Verify behaviour safely. Run Calif's bounded reproducer in a disposable lab JVM. A positive result confirms the memory-corruption behaviour on that runtime and hardware; it does not prove RCE against the application, which is a separate and much harder exercise.

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. 14 min read.

What happened, in plain words

Imagine you have spent years writing programs in Java. One of the main reasons people choose Java is that you do not have to think about memory. In older languages like C and C++, the programmer has to ask the computer for a chunk of memory, keep track of how big it is, and give it back when finished. Get that wrong and you can write data past the end of your chunk, trampling whatever sits next to it. Java was supposed to take that worry away: the Java Virtual Machine (JVM), the program that runs Java code, manages memory for you.

Then a researcher found that a very ordinary operation, decoding Base64 text, could write data outside the memory it was given. Base64 is a way of turning arbitrary bytes into plain letters and digits so they can travel safely through systems that only expect text. It is everywhere: in login headers, in email attachments, in tokens. Decoding it is supposed to be boring and safe.

The bug is called Java4Shell, tracked as CVE-2026-114938. A CVE is a public catalogue number for a known security flaw, so people around the world can refer to the same bug unambiguously. The write-up was published on 18 November 2026 by Shah Kaif, who describes the behaviour as found on his own test laptop.

The uncomfortable lesson: Java protects the code you write, but underneath it sits hand-written low-level code, and that lower layer can still have memory bugs. The safety net has a floor, and the floor is not Java.

From the original on infosecwriteups.com

Quick reference: affected versions and exploitation prerequisites

Before the details, here is the checklist version. "Affected" means the version contains the bug. "Patched" means the vendor has released a fixed build. A build is one specific compiled release of Java, identified by a full version number.

Vulnerable JDK / Java SE versions

A JDK (Java Development Kit) is the package that contains the JVM plus the tools to compile and run Java. Java SE (Standard Edition) is the name of the standard Java platform. GraalVM is an alternative Java runtime from Oracle.

Text
Product                                  Vulnerable Build       Patched BuildOracle Java SE 17                        17.0.21.0.3             17.0.21.1Oracle Java SE 21                        21.0.13.0.3             21.0.13.1Oracle Java SE 25                        25.0.5.0.3              25.0.5.1Oracle Java SE 27                        27.0.1.0.3             27.0.1.1Oracle Java 8 Enterprise Perf Pack       8u511b33-perf           Nov 17 2026 updateOracle GraalVM for JDK 17                17.0.21.0.3             Nov 17 2026 updateOracle GraalVM for JDK 21                21.0.13.0.3             Nov 17 2026 updateOracle GraalVM Enterprise Edition        21.3.20.0.3             Nov 17 2026 updateNOT AFFECTED: Standard Oracle Java SE 8 and 11 builds (per Red Hat advisory)

Line by line, in plain words:

  • The first column names the product, for example Oracle Java SE 17.
  • The second column is the vulnerable build, the exact version that contains the bug.
  • The third column is the patched build, the version you should move to.
  • The last line says that the ordinary Oracle Java SE 8 and 11 builds are not affected, according to a Red Hat advisory. An advisory is an official security notice from a vendor.

Not affected: standard Java SE 8 and 11 get to sit this one out.

The four conditions that must all line up

A vulnerability that needs several things to be true at once is much less dangerous than one that always works. Here, all four of these must hold:

  1. Unpatched OpenJDK 17.0.6+, or one of the affected Oracle or GraalVM builds in the table. OpenJDK is the open-source reference implementation of Java that most other Java distributions are built from.
  2. An x86-64 CPU with AVX-512 VBMI. A CPU is the processor chip. x86-64 is the family of processors used in most laptops and servers. AVX-512 is a set of instructions that let the CPU work on many bytes at once, like a kitchen robot that chops a whole row of vegetables in one stroke instead of one at a time. VBMI is a specific extension of that instruction set. The report names the exact features required: AVX512F, AVX512BW, AVX512VBMI and BMI2. AVX2, an older and more common set, does not count. If the machine is ARM64 (the processor family used in many phones and in Apple's newer laptops), it is not affected at all.
  3. The accelerated decoder actually enabled. Java has a fast path for Base64 decoding written in low-level code, and a slower ordinary path written in Java. The bug lives in the fast path. It can be switched off with the settings -XX:-UseBASE64Intrinsics or -XX:UseAVX=2. If it is off, this particular bug cannot be reached through it.
  4. Attacker-controlled input reaching Base64.getDecoder(). In plain terms, some data that an outsider can influence must be fed into the decoding function. Examples the report gives: Basic Auth headers (the username and password field a browser sends when a site asks you to log in), SAML (an XML-based single sign-on standard), file uploads, REST/GraphQL parameters (data sent to a web API), and CSRF tokens (hidden values in web forms used to stop forged requests).

An API, by the way, is the doorway a program offers to other programs: a defined set of requests it accepts and responses it returns. A token is a short string that stands in for something, usually proof that you are logged in or permission to do something.

How it works

The accelerated decoder processes Base64 input in big chunks using AVX-512 instructions, because reading one character at a time is slow. The bug appears in how it calculates the write mask near the end of the input, when padding is involved.

A mask here is a pattern of bits that says which bytes are allowed to be written. Think of a stencil: only the holes in the stencil let paint through. Padding is the = character at the end of Base64 text, used to fill out the last group when the input length does not divide evenly.

Certain malformed padding triggers an integer underflow in that calculation. An integer underflow is what happens when a counter that should never go below zero wraps around to a huge value, like a car odometer rolling backwards past zero and showing all nines. Instead of a mask sized for the correct number of output bytes, the routine produces an all-ones mask, meaning every bit is set: write all 64 bytes. It does not check whether there is room for 64 bytes. Usually there is not. The result is an out-of-bounds write into whatever heap memory happens to be sitting next door.

The heap is the general-purpose pool of memory a program uses for objects it creates while running. An out-of-bounds write means storing data past the end of the area you were given, into a neighbour's space.

The JVM does eventually catch on and throw an IllegalArgumentException. An exception is Java's way of reporting an error: the program stops that operation and signals that something went wrong. But this is like a bouncer turning someone away after they have already kicked the door in. The rejection is real. So is the broken door.

The report deliberately leaves out the exact byte-offset arithmetic, because it edges toward proof-of-concept territory, meaning a recipe someone could copy to attack systems. It points to Calif's original research for the numbers.

So why doesn't Java's famous memory safety save us here? Because the optimized intrinsic is hand-written native or assembly code sitting underneath Java's safety net, not inside it. An intrinsic is a built-in shortcut: instead of running the ordinary Java version of a function, the JVM swaps in a faster hand-written version. Native code means code compiled for the actual processor rather than for the JVM. Assembly is the lowest-level human-readable form of processor instructions. Java protects your code. It never promised the plumbing underneath was leak-proof too.

From memory corruption to RCE

RCE stands for remote code execution: an attacker getting their own commands to run on someone else's machine. An out-of-bounds write does not hand you a shell on a silver platter. A shell is a command prompt on the victim's machine. You still have to work for it.

Calif's research describes a chain, paraphrased in the report:

  1. Limited, clumsy control. The initial corruption gives the attacker only a little influence over nearby memory, not full control.
  2. Heap grooming. The attacker arranges objects in memory so that useful ones sit close to the damaged buffer. The report's analogy: rearranging furniture before a guest you do not trust shows up.
  3. A general write primitive. By manipulating array metadata (the bookkeeping data that describes an array, such as its length), the limited corruption is upgraded into a more general ability to write where the attacker wants. A primitive, in security jargon, is a small reliable capability you build bigger attacks from, like a single Lego brick.
  4. Reading memory. With the write primitive in place, the chain opens the door to reading memory, including tokens, keys and secrets. Calif compares this part to Heartbleed, a famous bug that leaked server memory to anyone who asked.
  5. Code execution. With enough of these primitives stacked up, application-specific exploitation can eventually reach code execution.

There is no one-size-fits-all exploit here. Every application's memory layout is its own weird little snowflake, so weaponizing this against any specific target is custom work, not copy-paste.

Applications discussed in the research are described as plausibly exposed, not guaranteed pwned. "Pwned" is informal for fully compromised.

  • Pre-auth: Keycloak, Jenkins, Jira, Confluence, Artifactory, PingFederate. Pre-auth means the attack can happen before anyone logs in.
  • Post-auth: Kafka Broker, Solr, Elasticsearch, Gerrit, Spinnaker. Post-auth means the attacker needs an account first.

And a desktop app does not get a pass just because it is not listening on a port. A Java client that opens a TLS connection to a malicious server can have corrupted data pushed right back at it. TLS is the encryption layer behind the padlock in your browser. Being the one who calls out does not make you safe from what calls back.

Detecting exposure

Exposure means whether your systems can actually be hit by this bug. The report gives four checks.

1. Figure out which JVM is actually running your app. Your default java -version is often lying by omission, because a machine can have several Java installations and the one on your path may not be the one running the service.

java -versionjcmd -ljcmd PID VM.version

Line by line:

  • java -version prints the version of the Java on your command path. It is a starting point, not proof.
  • jcmd -l lists the Java processes currently running on the machine, with their process IDs (PIDs). A PID is the number the operating system uses to identify a running program.
  • jcmd PID VM.version asks one specific running process, identified by its PID, which JVM version it is actually using.

2. Check CPU flags on Linux.

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

Line by line:

  • grep -m1 '^flags' /proc/cpuinfo reads the file /proc/cpuinfo, which the Linux kernel exposes to describe the processor, and prints the first line that starts with flags. Flags are the list of features the CPU supports.
  • tr ' ' '\n' replaces every space with a newline, so each feature sits on its own line.
  • grep -E '^(avx512f|avx512bw|avx512vbmi|bmi2)$' keeps only the four lines that exactly match one of the required features.

All four need to show up. On cloud instances, run this from inside the guest, because the hypervisor decides what your virtual machine actually gets to see, not whatever the provider's marketing page brags about. A hypervisor is the software that runs virtual machines and hands out hardware features to them.

3. Trace the code paths. Search your codebase for the decoder entry points:

Base64.getDecoder() / getUrlDecoder() / getMimeDecoder()

These are the three standard ways Java code asks for a Base64 decoder: the basic one, the URL-safe variant, and the MIME variant used for email-style content. Finding one of these in your codebase proves nothing by itself. Follow the data and see if anything an attacker touches actually ends up here.

4. Verify behaviour safely. Run Calif's bounded reproducer in a disposable lab JVM. A reproducer is a small program that demonstrates the bug. Disposable means a throwaway environment you can destroy afterwards. If it reproduces, you have confirmed the memory-corruption behaviour on that runtime and hardware. You have not proven RCE against your app. That is a separate, much harder exercise.

Mitigation

Mitigation means reducing the risk, whether or not you can fully fix it yet.

Patch first. Upgrade to the vendor-fixed build in the table and check the full build number. "I installed Java 17" is not the same sentence as "I installed the patched Java 17."

Can't patch right now? Buy time with:

-XX:-UseBASE64Intrinsics   -XX:UseAVX=2

These are JVM startup options. -XX:-UseBASE64Intrinsics turns off the accelerated Base64 decoder, so the ordinary Java implementation is used instead. -XX:UseAVX=2 is the other setting the report gives for buying time. The minus sign in front of a JVM option means "disable".

Also:

  • Inventory every bundled JVM hiding in your containers. A container is a lightweight isolated environment for running software, and it often ships its own Java inside.
  • Rebuild images after patching instead of just patching the host and hoping. An image is the template a container is created from.
  • Restart processes after flag changes. A flag that is not loaded is just a wish.
  • Check your authentication and upload endpoints before anything else.

Takeaways

  • Memory-safe languages still lean on unsafe native code somewhere underneath. The safety net has a floor, and that floor is C++.
  • CPU architecture is now part of your attack surface. Two servers can run the exact same app and still have completely different exposure, just because of what silicon they happen to sit on.
  • A thrown exception is not the same as "nothing happened". Sometimes the damage is already done by the time the error message shows up to apologise.
  • Version-number fingerprinting alone tells you almost nothing. You need runtime, CPU and code path all checked together. One out of three does not count.

Glossary

  • API: a defined doorway through which one program sends requests to another and receives responses.
  • Assembly: the lowest-level, human-readable form of the instructions a processor executes.
  • AVX-512: a set of processor instructions that operate on many bytes at once.
  • AVX-512 VBMI: a specific extension of AVX-512 named in the report as required for this bug.
  • Base64: an encoding that turns arbitrary bytes into plain letters, digits and a few symbols so they can travel through text-only systems.
  • Basic Auth header: the part of an HTTP request where a browser sends a username and password, Base64-encoded.
  • Build: one specific compiled release of a piece of software, identified by a full version number.
  • Container: a lightweight isolated environment for running software, often bundling its own runtime.
  • CPU: the processor chip that executes instructions.
  • CSRF token: a hidden value in a web form used to stop forged requests.
  • CVE: a public catalogue number for a known security vulnerability.
  • Exception: Java's mechanism for reporting that an operation failed.
  • GraalVM: an alternative Java runtime from Oracle.
  • Heap: the pool of memory a running program uses for objects it creates.
  • Heartbleed: a famous vulnerability that leaked server memory to remote attackers.
  • Hypervisor: software that runs virtual machines and decides which hardware features they see.
  • Image: the template from which a container is created.
  • Intrinsic: a built-in shortcut where the JVM swaps an ordinary Java function for a faster hand-written version.
  • Integer underflow: when a counter that should not go below zero wraps around to a very large value.
  • JDK: Java Development Kit, the package containing the JVM and the tools to compile and run Java.
  • JVM: Java Virtual Machine, the program that runs Java code and manages its memory.
  • Mask: a pattern of bits saying which bytes may be written, like a stencil.
  • MIME decoder: the Base64 variant used for email-style content.
  • Mitigation: reducing risk without necessarily removing the cause.
  • Native code: code compiled for the actual processor rather than for the JVM.
  • OpenJDK: the open-source reference implementation of Java.
  • Out-of-bounds write: storing data past the end of the memory area you were given.
  • Padding: the = characters at the end of Base64 text that fill out the last group.
  • Patch: a vendor-released fix for a vulnerability.
  • PID: the number the operating system uses to identify a running program.
  • Post-auth: an attack that requires the attacker to have an account first.
  • Pre-auth: an attack that can happen before anyone logs in.
  • Primitive: a small reliable capability used as a building block for a larger attack.
  • Pwned: informal for fully compromised.
  • RCE: remote code execution, an attacker getting their own commands to run on someone else's machine.
  • Reproducer: a small program that demonstrates a bug.
  • REST/GraphQL parameters: data sent to a web API.
  • SAML: an XML-based single sign-on standard.
  • Shell: a command prompt on a machine.
  • TLS: the encryption layer behind the padlock in a browser.
  • Token: a short string standing in for something, usually proof of login or permission.
  • URL decoder: the Base64 variant safe for use in web addresses.
  • x86-64: the processor family used in most laptops and servers.

More by Shah kaif

View all

5 more disclosed reports, best first.

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.