How to Find and Patch Java4Shell Across Bundled JDKs (2026)

Nov 19, 2026 · 9 min · Ajay Kumar

Java4Shell (CVE-2026-114938), disclosed on 17 November 2026, is a heap-corruption bug in OpenJDK's AVX-512 Base64 decoder that reaches pre-auth remote code execution in widely deployed Java apps. The patch is the easy part. The work is finding every copy of a vulnerable JDK across hosts, images and running pods, because most of them are bundled, not installed from the OS package manager. This guide gives you that inventory workflow, the patch-and-restart step, and the stop-gap flags for the services you cannot patch today.

Everything that touches a JVM below was tested on 19 November 2026 with OpenJDK 21.0.7 (Homebrew) on an ARM64 Mac. ARM is not a vulnerable platform, so this is a functional test of the detection and mitigation commands, not an exploit reproduction. I ran no trigger or exploit code.

Step 1: Understand what is in scope

A JVM is only exploitable if all three conditions hold. Rule a host or image out only when you can rule out at least one:

Condition In scope when Out of scope when
Runtime OpenJDK 17.0.6 or newer (or a build derived from it) OpenJDK 8, 11, or 17.0.5 and older
CPU x86-64 with AVX-512 VBMI (Ice Lake / Sapphire Rapids / Emerald Rapids / Granite Rapids; EPYC/Ryzen Zen 4+) ARM64 (Graviton, Ampere, Apple silicon); older x86 without AVX-512 VBMI
Input App decodes attacker-controlled Base64 with java.util.Base64 No external Base64 reaches the standard decoder

The runtime and CPU conditions are the two you can check mechanically. The input condition is harder to prove false, so treat any in-scope runtime on an in-scope CPU that faces untrusted traffic as vulnerable until patched.

Step 2: Check the CPU condition on x86-64 hosts

On Linux, the four AVX-512 flags that the vulnerable intrinsic needs:

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

All four must appear. If avx512vbmi is missing, that host cannot run the vulnerable code path, whatever JDK it has. Note that in a VM or container the flags reflect the physical CPU and any masking by the hypervisor, so check inside the actual runtime environment, not just the hardware spec sheet.

Step 3: Find every JDK and its real version

Do not trust java -version on PATH or the OS package version. Applications bundle their own runtime. List every java binary and ask each one:

# every java executable on the host, with its true version
for j in $(find / -type f -name java 2>/dev/null); do
  v=$("$j" -version 2>&1 | head -1)
  printf '%s\t%s\n' "$j" "$v"
done

On my test host this correctly reported the Homebrew JDK as openjdk version "21.0.7", separate from the system /usr/bin/java shim. A build whose version is 17.0.6 or newer is in scope on an affected CPU.

For a quick triage of a version string, this treats 17.0.6+ / 21 / 25 / 27 as in scope and 8 / 11 / older 17 as not:

# prints IN-SCOPE or ok for a version like 21.0.7 or 17.0.5
ver=$("$j" -version 2>&1 | sed -n '1s/.*version "\([0-9._]*\)".*/\1/p')
awk -v v="$ver" 'BEGIN{
  n=split(v,a,"[._]");
  maj=a[1]+0; min=a[2]+0; pat=a[3]+0;
  scope = (maj>=21) || (maj==17 && (min>0 || pat>=6));
  print (scope ? "IN-SCOPE " v : "ok " v)
}'

Confirm the exact patched build against the OpenJDK advisory; the fixed versions are 17.0.21.0.3, 21.0.13.0.3, 25.0.5.0.3 and 27.0.1.0.3 and later.

Step 4: Scan container images, not just hosts

A host package upgrade never touches a JDK baked into an image. Check each image you run:

# version of the java inside an image
docker run --rm --entrypoint java IMAGE -version

# or find a bundled JDK that is not the entrypoint
docker run --rm --entrypoint sh IMAGE -c \
  'find / -type f -name java 2>/dev/null | while read j; do "$j" -version; done'

If you keep an SBOM per image (see the Syft how-to), query that instead of launching every image. For images you build, the fix is to bump the base image or the JDK package in the Dockerfile and rebuild; see hardened container images for base-image choices. A rebuilt image still has to be rolled out, because the old image keeps running until you replace it.

Step 5: Find vulnerable JDKs in a running Kubernetes cluster

A rebuilt image in the registry does nothing until the pods restart onto it. Find the Java versions actually running:

# ask each pod's main container for its java version
kubectl get pods -A -o jsonpath='{range .items[*]}{.metadata.namespace}{" "}{.metadata.name}{"\n"}{end}' \
| while read ns pod; do
    v=$(kubectl exec -n "$ns" "$pod" -- java -version 2>&1 | head -1)
    case "$v" in *version*) printf '%s/%s\t%s\n' "$ns" "$pod" "$v";; esac
  done

This only reaches containers that have java on the path; for others, exec a find as in Step 4. After you patch, re-run this to confirm the running pods report a fixed version, not just the registry.

Run detection against clusters deliberately. Keep KUBECONFIG pointed at the cluster you mean to touch, and remember kubectl exec runs a process in production pods.

Step 6: Patch and restart

The patch is a JDK upgrade to the fixed build. The step people miss is the restart: a running JVM keeps the vulnerable code until the process restarts. So:

  1. Update the JDK (OS package, bundled runtime, or image base) to the patched version.
  2. Restart or redeploy every service that uses it. For Kubernetes, roll the Deployment (kubectl rollout restart deployment/NAME -n NS) so pods come up on the rebuilt image.
  3. Re-run Step 3 or Step 5 to confirm the running process reports the patched version.

Patch the internet-facing apps with demonstrated pre-auth RCE first: Keycloak, Jira, Confluence, Artifactory, Jenkins, PingFederate.

Step 7: Mitigate the services you cannot patch yet

OpenJDK accepts two start-up flags that remove the vulnerable path. From my test on OpenJDK 21.0.7:

$ java -XX:-UseBASE64Intrinsics -version
openjdk version "21.0.7" 2025-04-15          # starts normally

$ java -XX:UseAVX=2 -version
Unrecognized VM option 'UseAVX=2'            # on ARM: fails to start
Error: Could not create the Java Virtual Machine.

So:

  • -XX:-UseBASE64Intrinsics disables the hardware-accelerated Base64 encoder and decoder. It is accepted on every architecture, which makes it the safer flag to template across a fleet. (UseBASE64Intrinsics defaults to true, so you are turning an optimisation off.)
  • -XX:UseAVX=2 disables AVX-512 but is x86-64 only. As shown above, OpenJDK on ARM rejects it and the JVM will not start. Never push this flag to a mixed-architecture fleet without gating on uname -m.

Add the flag through JAVA_TOOL_OPTIONS or the app's JVM args, and restart. Both flags may slow Base64-heavy workloads, and neither replaces the patch; they buy time only.

Troubleshooting

Symptom Likely cause Fix
Host package upgraded but app still vulnerable App bundles its own JDK, or the JVM has not restarted Patch the bundled runtime (Step 4) and restart the process (Step 6)
Unrecognized VM option 'UseAVX=2' and JVM won't start Flag pushed to an ARM64 host Use -XX:-UseBASE64Intrinsics instead; it works on all architectures
find / -name java returns nothing in a container Minimal/distroless image with no shell or find Use --entrypoint java IMAGE -version, or read the image's SBOM
Pods still report an old version after rollout Deployment still references the old image tag or a cached digest Repin the tag/digest and kubectl rollout restart; verify with Step 5
CPU check shows no avx512vbmi but you still want to be safe Host genuinely cannot run the vulnerable path Prioritise elsewhere; this host is out of scope on the CPU condition
WAF rule logging lots of matches Legitimate Base64 tokens resembling the trigger Keep the rule in Log, review in Security Events before switching to Block

FAQ

Do I need to patch Java 8 or Java 11?

No. Java4Shell affects OpenJDK 17.0.6 and newer. OpenJDK 8, 11 and 17.0.5 or earlier do not have the vulnerable AVX-512 Base64 intrinsic in the form the CVE describes. Confirm the exact version with java -version on the actual binary, because a host can run several JDKs.

Is disabling the Base64 intrinsic safe for production?

It is safe functionally: -XX:-UseBASE64Intrinsics only turns off a hardware-accelerated code path and falls back to the standard Java implementation, which produces the same results. The cost is performance for workloads that decode large amounts of Base64. It is a stop-gap, not a substitute for upgrading the JDK.

How do I check a distroless or minimal container with no shell?

Run the image with --entrypoint java IMAGE -version to ask the bundled runtime directly, or read the image's SBOM if you generate one at build time. If neither is possible, rebuild from a base image whose JDK version you control rather than trying to inspect the running container.

Does restarting really matter if I have patched the files?

Yes. A JVM loads its code at start and keeps running the old intrinsic until the process restarts. Patching the files on disk or in the image does nothing for a process that is already running, so every updated service must be restarted or redeployed.

Related: Java4Shell explained, How to Generate an SBOM With Syft in GitHub Actions and How to Scan Container Images with Trivy and Grype.

Spot an error or something out of date? Email me and I will fix it and log it on the corrections page.

I'm Ajay Kumar — I build and operate PandaStack, an open-source Firecracker microVM cloud for AI agents, and write about the infrastructure and tooling around it.

Need this kind of infrastructure work? See what I do or email hello@ajayk.sh.


Related