Technology

Java4Shell Took an AI an Hour to Find and Four Lines to Fix

A researcher told an AI to look at Java's fastest code. It found a critical hole in an hour, for under $200. Oracle's fix is out; the free builds most teams run are still waiting.

Quang Luong had just finished an exploit for a phone vendor when he got bored and pointed an AI at Java. He told Codex to audit the places where complex systems cross boundaries, the JIT compiler, the intrinsics, the widely used APIs, the cryptography, and to keep looking until it found something real. The first results were useless, unreachable or unrealistic, and he prompted harder anyway. An hour later the model brought him a memory-corruption bug in Java’s Base64 decoder. Two hours after that he had a working exploit. The token bill was under $200. Calif had done this once before, weeks earlier, with PHP2Shell, the same kind of memory corruption in PHP’s core.

The bug lives in hand-written assembly that OpenJDK uses to decode Base64 fast on x86 processors with AVX-512 VBMI instructions. A malformed input, 64 letter A’s followed by a single equals sign, 65 characters in all, makes the decoder compute a negative output length, and the write mask stays fully open. The decoder allocates a 50-byte buffer and writes 64 bytes into it, 62 of them past the end. Java rejects the input a moment later. By then the neighbouring memory is already corrupted. Calif’s researchers turned that fixed spill into a heap leak they call JavaBleed. The leak can expose private keys, tokens and personal data before they turned it into remote code execution. They demonstrated it without a login against Keycloak, Jira, Confluence, JFrog Artifactory, Jenkins and PingFederate in their default configurations, and after login against Kafka, Solr, Elasticsearch, Gerrit and Spinnaker.

The runtime has to be OpenJDK 17.0.6 or newer, or any release from 18 up. The processor has to be x86-64 with AVX-512 VBMI, Intel Xeon from Ice Lake on, AMD EPYC and Ryzen from Zen 4 on. And attacker-controlled data has to reach Java’s built-in Base64 decoder, which happens constantly: HTTP Basic authentication, JWT tokens, SAML, file uploads. ARM servers are outside the path entirely. Java 8 and 11 are too. They never got the fast decoder. Upwind reproduced the overflow on an AWS c6i instance and found the boundary exact: 17.0.5 is clean, 17.0.6 is not.

The remote-code-execution claim was disputed before Tuesday. Equixly, reading the same decoder, argued the realistic outcome was a crashed JVM, because the decoder chooses the bytes it writes and the attacker does not. Upwind’s team reproduced the 62-byte overflow on real hardware. Calif’s write-up, published at 21:11 UTC, shows the full chain. A writer primitive overwrites a buffer length, a reader primitive leaks the heap, a repair step keeps the JVM alive, and a bounded proof of concept reproduces the overwrite on any affected JDK. The crash reading was a reading of the code before the write-up existed, and the RCE claim is a demonstrated chain with the reproduction attached. The score still splits by system, 9.2 under CVSS 4.0 from Calif and 8.1 under CVSS 3.1 from Oracle, and the two numbers cannot be compared directly.

The fast decoder was not always there. OpenJDK added it in June 2021 as JDK-8268276, a Base64 optimization for x86 using AVX-512, and its own benchmark showed decoding running 2.6 times faster on average, nearly 20 times faster on large buffers. It shipped in JDK 18, was backported to Java 17 as JDK-8296735 in November 2022, and first reached Java 17 users in 17.0.6 in January 2023. That is why the boundary sits where it does. The same decoder had already failed once: in December 2023 a data-loss bug in it, JDK-8321599, appeared only on AVX-512 processors and vanished when the JVM was limited to AVX2. It was fixed in 17.0.11 and 21.0.3. The decoder stayed.

The fix is four lines. The mainline OpenJDK change adds a guard that sends a padded Base64 tail shorter than one complete block to the plain Java handler instead of the optimized routine. Oracle shipped fixed builds the same day the flaw was disclosed. The .1 line, 17.0.21.1 and the rest, arrived as part of a November update containing 11 Java SE fixes, all remotely exploitable without a login. The builds most teams actually run had nothing as of Tuesday night: Eclipse Temurin, Amazon Corretto, Azul Zulu, the Microsoft build, Red Hat’s and the Linux distributions had published no fixed build naming the CVE. Until they do, Calif’s stopgaps are two JVM flags, -XX:-UseBASE64Intrinsics to switch the fast decoder off, or -XX:UseAVX=2 to switch AVX-512 off, and both need a restart to take effect.

On Threads, lvchaoshuai posted within the hour: “Wait, Java has a memory-corruption vulnerability, in Base64?!” Darryl Morris, an Ethereum developer, wrote on X: “wat? All 3 Billion of them?” His attached image was a Java install window boasting that 3 billion devices run Java. Elijah Smith, a software engineer, wrote: “is this funnier the second time”. His attached image was a Java logo over the words “SHUT IT DOWN.” The joke was the same one Low Level, a security creator with more than a million YouTube subscribers, had posted minutes earlier: “if you’re running a networked Java application turn it off.”

The one practical voice in the first hour was Suresh G, a Java and Kotlin programmer, who posted: “You can mitigate with -XX:-UseBASE64Intrinsics option”. The sharpest was Elton Froth, who read Calif’s write-up and complained: “Cool work but for goodness sake please have a human actually write the write up. Reads like total AI slop and if this is the future of “communication” god help us.” The officials’ language is critical, pre-authentication, patch immediately. The people who run the software answered with disbelief, a joke about switching it off, and a flag. In the posts reviewed in the first hour, none of the ordinary voices asked whether their own systems were affected, and none said they were patching tonight. The flaw landed first as a joke; the patching comes second. And Froth’s complaint lands on the piece’s own premise: the write-up that celebrates the centaur hacker, part human and part AI, reads to at least one reader like the AI wrote it alone.

Java4Shell will be called the next Log4Shell, and the comparison fails in four places. Log4Shell was a flaw in a logging library, Log4j, that any Java application could carry on any processor. A string in a log message triggered it. It scored 10.0, was exploited in the wild within days, and drew a CISA emergency directive and four successive fixes. Java4Shell is a flaw in the runtime itself, on specific processors only, with no universal exploit, each application needing its own chain, and as of Tuesday night there was no reported exploitation, no public exploit, and the CVE record was still reserved. The name is a brand now, not a diagnosis. Calif’s own question is the one the field has not taken up: the fast decoder helps applications that decode enormous amounts of data, and it shipped to everyone else too, including applications that gain little from it. “What can we delete?” the write-up asks, and calls the work vibe-uncoding, combing a codebase with AI to find the parts a system actually needs and removing the rest.

Calif is holding back the application-specific exploits until users have had a chance to upgrade. No exploitation in the wild had been reported, and the flaw had not been added to CISA’s list of exploited vulnerabilities.