Skip to content

Latest commit

 

History

History
194 lines (136 loc) · 6.54 KB

FIX.md

File metadata and controls

194 lines (136 loc) · 6.54 KB

Fixing Java4Shell (CVE-2026-114938)

The only complete fix is a patched JVM plus a restart. A framework upgrade, a WAF rule, or a new application server version does not replace the JDK.

1. Find every JVM

Start with the processes that are running now:

ps -eo pid,comm,args | grep -i '[j]ava'
jcmd -l

jcmd -l lists attachable JVMs. It may miss processes in other PID namespaces, containers, or under a different user. Check those separately:

docker ps
podman ps
kubectl get pods -A

Common places where a JVM hides:

  • Application servers: Tomcat, Jetty, WildFly, WebLogic, WebSphere, GlassFish.
  • Products that bundle a JVM: Jenkins, Solr, Elasticsearch, OpenSearch, Kafka, Keycloak, Jira, Confluence, Artifactory, PingFederate.
  • Build and CI agents, Gradle and Maven daemons, IDEs, and code scanning tools.
  • Sidecars, batch jobs, scheduled tasks, and short-lived containers.
  • Desktop and developer machines, which can reach production credentials.

Check every JVM, not only the one on PATH.

2. Upgrade to a fixed build

JDK Fixed build
17 17.0.21.1
21 21.0.13.1
25 25.0.5.1
27 27.0.1.1

Oracle's November 2026 CPU also lists 8u513 and 11.0.33.1. The OpenJDK risk matrix for CVE-2026-114938 covers 17, 21, 25, and 27, but keep 8 and 11 on the same patch cycle.

All OpenJDK-based distributions share the vulnerable code. Use the fixed build from your vendor:

Vendor Where to check
Oracle November 2026 Critical Patch Update
Eclipse Temurin / Adoptium November 2026 release notes
Amazon Corretto Corretto 17, 21, 25, 27 release notes
Azul Zulu Zulu November 2026 release
BellSoft Liberica Liberica release notes
SAP SapMachine SapMachine release notes
Red Hat Red Hat build of OpenJDK errata
GraalVM GraalVM November 2026 release notes

Package manager examples. Confirm that the repository actually contains the fixed build before rolling out:

# Debian or Ubuntu
sudo apt update
sudo apt install --only-upgrade openjdk-17-jre-headless

# RHEL, Fedora, or CentOS Stream
sudo dnf update java-17-openjdk-headless

# Alpine
sudo apk upgrade openjdk17-jre-headless

For containers, update the base image digest and rebuild. Do not assume latest contains the fix:

FROM eclipse-temurin:21-jre

Pin the fixed build or digest in production, rebuild the image, and redeploy. Check the JVM inside the image, not only the JVM on the build host.

3. Restart and verify

A package upgrade does not replace a running process. Restart every affected service:

sudo systemctl restart tomcat
docker restart <container>
kubectl rollout restart deployment/<name>

Then verify the running build:

jcmd -l
jcmd <pid> VM.version
jcmd <pid> VM.system_properties | grep '^java.version='

Also check the default binary and its real path:

java -version
readlink -f "$(command -v java)"

For a container:

docker exec <container> java -version
docker exec <container> jcmd 1 VM.version

A host can run several JVMs. A patched default java does not prove that every service is patched.

4. Interim mitigation

If you cannot patch immediately, disable the vulnerable intrinsic:

-XX:-UseBASE64Intrinsics

Or disable AVX-512 on x86-64:

-XX:UseAVX=2

Apply the flag to the JVM that runs the application, not only to an interactive shell. Examples:

# Tomcat
export CATALINA_OPTS="$CATALINA_OPTS -XX:-UseBASE64Intrinsics"

# Spring Boot or a plain java command
export JAVA_TOOL_OPTIONS="-XX:-UseBASE64Intrinsics"

# systemd unit
Environment="JAVA_TOOL_OPTIONS=-XX:-UseBASE64Intrinsics"

JAVA_TOOL_OPTIONS is read by every JVM that starts in that environment, including child processes. JDK_JAVA_OPTIONS is read only by the java launcher. Pick deliberately.

Do not use -XX:UseAVX=2 on ARM64. The option is not recognized there and the JVM will fail to start. -XX:-UseBASE64Intrinsics is the safer cross-platform choice.

Verify the effective flag:

java -XX:+PrintFlagsFinal -version | grep -E 'UseBASE64Intrinsics|UseAVX'

UseBASE64Intrinsics should be false, or UseAVX should be 2 or lower.

The mitigation has a performance cost for Base64-heavy workloads. It also has to be applied to every JVM, including containers and embedded runtimes. Upgrading remains the correct fix.

Defense in depth

  • Restrict Actuator, Solr admin, Jolokia, and JMX endpoints to a management network.
  • Block or alert on malformed Base64 in Authorization: Basic headers at the edge.
  • Reject requests with anomalous Base64 padding and high-volume Basic auth from a single source.
  • Do not treat a WAF rule as a fix. It can be bypassed, and it may break legitimate clients.

5. Check for exploitation

Look for:

  • hs_err_pid*.log files with SIGSEGV in G1 GC or StubRoutines.
  • Repeated IllegalArgumentException from the Base64 decoder in application logs.
  • Sudden JVM crashes or restarts after Basic auth traffic.
  • Unusual volumes of Basic auth requests, especially with malformed padding.
  • Unexpected heap growth, heap dumps, or data returned from endpoints that should not expose memory.

If you suspect exploitation, isolate the host, preserve logs and crash dumps, rotate credentials and tokens that the JVM could read, and investigate the application's data exposure.

6. Verify the rollout

  • Every JVM is on 17.0.21.1, 21.0.13.1, 25.0.5.1, 27.0.1.1, or a vendor fixed build.
  • Every JVM and container was restarted after the upgrade.
  • jcmd <pid> VM.version reports the fixed build for every application process.
  • Base images and CI images are pinned to fixed builds.
  • Interim flags are removed after the upgrade, unless the flag is intentional.
  • Management endpoints are not exposed to untrusted networks.
  • The network scanner reports no AFFECTED targets, or every exception is documented.
  • Crash logs and Base64 exception rates were reviewed for signs of exploitation.

Vendor backports

Version strings are not authoritative patch evidence. A vendor can backport the fix while reporting an older upstream version. Check the vendor advisory for the build you run, and use jcmd <pid> VM.version plus the vendor release notes.

References