Containers

Patch Java4Shell (CVE-2026-114938) in Spring Boot Apps

A Spring Boot app gets the Java4Shell (CVE-2026-114938) fix from its Java runtime, not from a Spring release. The bug sits in the HotSpot Base64 decoder, so the patch is a rebuild on a fixed JDK, and how the image was built decides whether a rebuild is enough.

Original content from computingforgeeks.com - post 192084

Below you will find which build routes already produce a fixed JDK, how to read the Java build of a running app, and how to rebuild or flag each kind of image. The Java4Shell CVE-2026-114938 overview explains the bug itself. We checked every build route in the table on 19 November 2026 with a Spring Boot 4.1 app on a Google Cloud c3 instance running Ubuntu 24.04 and Docker.

Which Spring Boot builds carry the fix?

A build is fixed when the JVM inside reports 17.0.21.1, 21.0.13.1, 25.0.5.1 or 27.0.1.1 or later, and the build route decides which one you get. We built the same Java 21 app every way below and read the runtime inside each result, never the tag or the buildpack label:

Build routeJava inside the imageStatus on 19 Nov 2026
spring-boot:build-image with the defaults (builder pulled fresh)Liberica 21.0.13.1+5Fixed
spring-boot:build-image with a builder older than 0.0.218 (pushed 22:50 UTC on 18 November) and pullPolicy=IF_NOT_PRESENTLiberica 21.0.13.0.3+5Vulnerable
Any buildpack image built before the fixed builder (pushed 22:50 UTC on 18 November)The Liberica build of that dayVulnerable until rebuilt
Jib with its default base (eclipse-temurin:21-jre)Temurin 21.0.13+9Vulnerable
Jib with amazoncorretto:21 as the baseCorretto 21.0.13.1+2Fixed
Dockerfile FROM eclipse-temurin:21-jreTemurin 21.0.13+9Vulnerable
Dockerfile FROM amazoncorretto:21Corretto 21.0.13.1+2Fixed
Executable jar on Ubuntu 24.04 after USN-9156-1Ubuntu 21.0.13.1+2Fixed

The buildpack route is in the best shape. Paketo’s Java buildpack 22.9.1 shipped the fixed Liberica builds on 18 November (paketo-buildpacks/java#2456), and Spring Boot pulls the builder fresh on every build by default. Jib and the common Dockerfile base are the problem. Both land on the Eclipse Temurin Docker images, which had not been rebuilt on the fixed Temurin release when we checked, so those builds stay vulnerable however often you run them.

Only hosts whose CPUs report all four flags Calif checks (avx512f, avx512bw, avx512vbmi and bmi2) can run the vulnerable code, and the CPU check in the overview tells you which of yours qualify, so start the rebuilds on those hosts. Our c3 host (Intel Xeon Platinum 8481C) has all four, so every vulnerable row above was exposed on it.

How do you see which Java a Spring Boot app runs?

Spring Boot prints the Java version in its first startup line, so the logs of a running app already answer the question, even on a buildpack image that has no shell. We started the image built on a stale builder and the one built with the defaults, then read both banners:

for t in stale default; do docker logs app-$t 2>&1 | grep -oE 'Starting DemoApplication v[^ ]+ using Java [0-9.]+'; done

The fixed image reports 21.0.13.1, and the stale one reports the last vulnerable build. Both images run the same app and only the builder differed, so this line is the quickest way to tell them apart in production.

Starting DemoApplication v0.0.1-SNAPSHOT using Java 21.0.13.0.3
Starting DemoApplication v0.0.1-SNAPSHOT using Java 21.0.13.1

Read that number against the fixed builds, not against its length. The vulnerable Temurin 21 build shows up in the banner as plain 21.0.13, and the vulnerable Liberica build as 21.0.13.0.3, so neither a short nor a long string means safe by itself. If the app exposes the actuator, the info endpoint can report the same thing with the vendor and full runtime string. It is off by default, so we switched on the Java contributor with two environment variables:

docker run -d --name app-info -p 8081:8080 -e MANAGEMENT_INFO_JAVA_ENABLED=true -e MANAGEMENT_ENDPOINTS_WEB_EXPOSURE_INCLUDE=info demo:default
curl -s localhost:8081/actuator/info | jq -c '.java | {version, vendor: .vendor.name, runtime: .runtime.version}'

The endpoint names BellSoft and the fixed runtime. The vendor field helps when a fleet mixes bases, because the same version number can come from Liberica, Temurin or Corretto, and the fix landed on different days for each. Read it together with the runtime string, so you know whose release notes to check.

{"version":"21.0.13.1","vendor":"BellSoft","runtime":"21.0.13.1+5-LTS"}

Leave the endpoint closed to the internet if you turn it on. Version strings are exactly what someone scanning for Java4Shell targets wants, so expose it on the management port or behind your monitoring network only. If you cannot do that, stick to the log banner, which tells you the same build without opening anything.

How do you fix an image built with build-image?

Rebuild it. The Maven and Gradle plugins default to the paketobuildpacks/builder-noble-java-tiny:latest builder with a pull policy of ALWAYS, per the Spring Boot build-image docs, so a plain rebuild fetches the current builder and the fixed JDK with it. We rebuilt the app with the defaults and kept only the builder and JDK lines of the output:

./mvnw -B -DskipTests spring-boot:build-image -Dspring-boot.build-image.imageName=demo:rebuilt

The builder digest is the one Docker Hub lists for both latest and 0.0.218, pushed late on 18 November, and it brings Liberica buildpack 11.10.6. Look for that digest in your own CI log, because the tag name alone does not tell you when the builder was pulled.

> Pulled builder image 'paketobuildpacks/builder-noble-java-tiny@sha256:cd34e9cb5f55980b902d9b1c4a354a720b407a512b80caef9e70791b4ab6dbf6'
[creator]     Paketo Buildpack for BellSoft Liberica 11.10.6
[creator]       BellSoft Liberica JRE 21.0.13: Contributing to layer
Successfully built image 'docker.io/library/demo:rebuilt'

Do not let the JRE 21.0.13 label fool you in either direction. The buildpack prints three version fields for every 21.0.13 build, fixed or not, so the build log cannot tell you which one you got. Check the JVM inside the image instead:

docker run --rm --entrypoint /layers/paketo-buildpacks_bellsoft-liberica/jre/bin/java demo:rebuilt -version 2>&1 | sed -n 2p

That prints the full build, and 21.0.13.1 is the fixed one. We called the JRE path directly because the image has no shell, and this only reads the version, so it tells you nothing the startup banner would not.

OpenJDK Runtime Environment (build 21.0.13.1+5-LTS)

When does a rebuild still give you the old JDK?

A rebuild only helps if it reaches the new builder. Some CI setups set pullPolicy to IF_NOT_PRESENT to save time, or pin a builder tag in the pom.xml, and both can leave you on a pre-fix builder: the first reuses what the runner cached, the second always fetches the old tag you pinned. To show it, we put the 16 November builder (0.0.216) on the host under the latest tag, the way a CI cache would hold it, and built with that policy:

docker pull -q paketobuildpacks/builder-noble-java-tiny:0.0.216 && docker tag paketobuildpacks/builder-noble-java-tiny:0.0.216 paketobuildpacks/builder-noble-java-tiny:latest
./mvnw -B -DskipTests spring-boot:build-image -Dspring-boot.build-image.imageName=demo:stale -Dspring-boot.build-image.pullPolicy=IF_NOT_PRESENT

No pull happens, because the policy only fetches a builder that is missing, so the old Liberica buildpack does the build. Nothing in the output warns you.

Building image 'docker.io/library/demo:stale'
[creator]     ===> BUILDING
[creator]     Paketo Buildpack for BellSoft Liberica 11.10.5
[creator]       BellSoft Liberica JRE 21.0.13: Contributing to layer
Successfully built image 'docker.io/library/demo:stale'

Both builds print the same label, yet they carry different JVMs. Reading the runtime inside both images shows the gap that the build log hides.

for t in stale default; do printf '%-8s ' $t; docker run --rm --entrypoint /layers/paketo-buildpacks_bellsoft-liberica/jre/bin/java demo:$t -version 2>&1 | sed -n 2p; done

The stale image carries the last vulnerable Liberica build. It would pass a review of the build log, so the runtime check belongs in the pipeline, not only in an audit.

stale    OpenJDK Runtime Environment (build 21.0.13.0.3+5-LTS)
default  OpenJDK Runtime Environment (build 21.0.13.1+5-LTS)

The trigger Calif published, run unmodified against the JVM in each image, agreed: it printed REPRODUCED on the stale image and NOT REPRODUCED on the default one. If your build pins a builder or pulls only when missing, check these before you trust a rebuild:

  • The pullPolicy in the plugin configuration or CI command is ALWAYS, or the runner pulls the builder before the build.
  • A pinned builder tag is 0.0.218 or later for builder-noble-java-tiny.
  • The build log shows Paketo Buildpack for BellSoft Liberica 11.10.6 or later.
  • java -version inside the new image prints 17.0.21.1, 21.0.13.1, 25.0.5.1 or 27.0.1.1 or later.

We ran the Maven goal only. The Gradle bootBuildImage task documents the same default builder and pull policy, so the same checks apply there, but we did not build with Gradle in this lab.

What about Jib and Dockerfile builds?

Change the base image, because rebuilding on the default one gets you nothing yet. Jib’s documented default base is eclipse-temurin:{8,11,17,21,25}-jre, and a fresh Jib build of our app pulled the Java 21 one (we ran jib-maven-plugin 3.4.5; the current 3.5.2 documents the same default base):

./mvnw -B -DskipTests package com.google.cloud.tools:jib-maven-plugin:3.4.5:dockerBuild -Dimage=demo:jib
docker run --rm --entrypoint java demo:jib -version 2>&1 | sed -n 2p

Jib names the base it used, and the runtime inside is the unfixed Temurin build. The auth line is Jib’s normal retry against Docker Hub, and the build carries on after it.

Getting manifest for base image eclipse-temurin:21-jre...
The base image requires auth. Trying again for eclipse-temurin:21-jre...
Using base image with digest: sha256:ca73b4d3961703d6d7830a4361f49ef0478f8f28b39defc07bb72f4cc7f834f6
Built image to Docker daemon as demo:jib
OpenJDK Runtime Environment Temurin-21.0.13+9 (build 21.0.13+9-LTS)

That image printed REPRODUCED under the Calif trigger. Point Jib at a base that already carries the fix. On the command line that is -Djib.from.image, and in the pom.xml the same value goes in <from><image>:

./mvnw -B -DskipTests com.google.cloud.tools:jib-maven-plugin:3.4.5:dockerBuild -Djib.from.image=amazoncorretto:21 -Dimage=demo:jib-corretto
docker run --rm --entrypoint java demo:jib-corretto -version 2>&1 | sed -n 2p

The Corretto base gives the fixed build, and the trigger printed NOT REPRODUCED against it. Its Docker images carried the fixed build by 18 November, which is why we used it here, so you can move a Jib build today without waiting on Temurin. Set the base in the pom.xml rather than on the command line once you settle on one, so every developer and pipeline builds the same thing.

OpenJDK Runtime Environment Corretto-21.0.13.1.2 (build 21.0.13.1+2-LTS)

A Dockerfile works the same way, because the FROM line is where the JDK comes from. We built one jar on both bases with a build argument, so only that line differed between the two images. Any change in the result therefore comes from the base alone:

ARG BASE=eclipse-temurin:21-jre
FROM ${BASE}
COPY target/demo-0.0.1-SNAPSHOT.jar /app/app.jar
ENTRYPOINT ["java", "-jar", "/app/app.jar"]

Build with --pull so Docker cannot reuse an older cached base. Without it, a host that pulled amazoncorretto:21 last week would build on last week’s JDK and look fixed in your Dockerfile while it is not.

for b in eclipse-temurin:21-jre amazoncorretto:21; do t=df-${b%%:*}; docker build -q --pull --build-arg BASE=$b -t demo:$t . >/dev/null && printf '%-24s ' $b && docker run --rm --entrypoint java demo:$t -version 2>&1 | sed -n 2p; done

Only the Corretto build is fixed. The jar and the Dockerfile are identical in both, so the base image alone decides your exposure.

eclipse-temurin:21-jre   OpenJDK Runtime Environment Temurin-21.0.13+9 (build 21.0.13+9-LTS)
amazoncorretto:21        OpenJDK Runtime Environment Corretto-21.0.13.1.2 (build 21.0.13.1+2-LTS)

Corretto is one choice, not the only one. Our Java4Shell guide for Docker and Kubernetes lists the other fixed bases we tested (distroless, Microsoft, Zulu, SapMachine, Chainguard), so pick the one closest to the distro your app expects. Switching away from Temurin can be temporary: once the official eclipse-temurin images move to the fixed release, you can switch back.

How do you mitigate an image you cannot rebuild today?

Set -XX:-UseBASE64Intrinsics through JAVA_TOOL_OPTIONS when the container starts. The Paketo launcher already uses that variable for its memory settings, and the Paketo Java docs say flags you set there are added to its own. We started the vulnerable stale image with the flag and checked what the JVM picked up:

docker run -d --name app-flag -e JAVA_TOOL_OPTIONS=-XX:-UseBASE64Intrinsics demo:stale
docker logs app-flag 2>&1 | grep -E 'Picked up|Started DemoApplication' | cut -c1-400

Your flag sits next to the memory flags from the buildpack, and the app still starts normally. The line is cut at 400 characters, and the rest is more memory settings.

Picked up JAVA_TOOL_OPTIONS: -XX:-UseBASE64Intrinsics -Djava.security.properties=/layers/paketo-buildpacks_bellsoft-liberica/java-security-properties/java-security.properties -XX:+ExitOnOutOfMemoryError -XX:MaxDirectMemorySize=10M -Xmx14488975K -XX:MaxMetaspaceSize=81340K -XX:ReservedCodeCacheSize=240M -Xss1M -XX:+UnlockDiagnosticVMOptions -XX:NativeMemoryTracking=summary -XX:+PrintNMTStatistics -
2026-11-19T10:28:28.050Z  INFO 1 --- [demo] [           main] com.example.demo.DemoApplication         : Started DemoApplication in 1.987 seconds (process running for 2.304)

A “Picked up” line proves the JVM read the variable, but your change record wants the live value of the flag. The tiny buildpack image has no shell and no jcmd, so run jcmd from a throwaway JDK container that shares the app container’s process namespace. Attach only works as the same user, so read the image’s user first:

docker inspect -f {{.Config.User}} demo:stale

Buildpack images run as the cnb user, with these IDs. Other builders can use different IDs, so read them from your own image instead of copying ours.

1002:1001

Pass exactly that user and group to the helper container, because attach checks both. Then ask the flagged app and an unflagged one for the flag:

docker run --rm --pid=container:app-flag --user 1002:1001 eclipse-temurin:21-jdk jcmd 1 VM.flags -all | grep UseBASE64Intrinsics
docker run --rm --pid=container:app-stale --user 1002:1001 eclipse-temurin:21-jdk jcmd 1 VM.flags -all | grep UseBASE64Intrinsics

The flagged JVM has the intrinsic off, sourced from the environment, and the unflagged one still runs it. That pair of lines is the evidence to keep for every instance you mitigate instead of rebuild.

     bool UseBASE64Intrinsics                      = false                                     {product} {environment}
     bool UseBASE64Intrinsics                      = true                                      {product} {default}

Our first try used group 1000 instead of 1001, and it failed with an error that points at the wrong cause. The JVM ignores an attach request from a different user and group, so jcmd times out as if no JVM were there:

com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file /tmp/.java_pid1: target process 1 doesn't respond within 10500ms or HotSpot VM not loaded

On Kubernetes the same variable goes in the container’s env, and the Docker and Kubernetes guide shows that rollout. Do not swap in -XX:UseAVX=2 as a shortcut: a JVM on arm64 does not recognise it and refuses to start, which breaks multi-arch images.

How do you find every Spring Boot container still on an old Java?

Use the same startup banner across every running container. This loop needs nothing inside the images, so it works on buildpack and distroless images that have no shell. It is also quick enough to run on every host in a fleet, because it only reads logs that Docker already keeps:

#!/bin/sh
# Java build of every running Spring Boot container, read from its startup banner line.
for c in $(docker ps -q); do
  v=$(docker logs "$c" 2>&1 | grep -m1 -oE 'using Java [0-9.]+' | cut -d' ' -f3)
  [ -n "$v" ] && printf '%-14s %-22s %s\n' "$(docker inspect -f '{{.Name}}' "$c" | tr -d /)" "$(docker inspect -f '{{.Config.Image}}' "$c")" "$v"
done

We saved it as inventory.sh and ran it with every lab app up. It reads only logs and labels, so it is safe to run on a production host, and it needs no access to the app itself.

sh ~/inventory.sh

Each container gets one line with its image and Java build. Sort or filter it however suits your fleet, because the third column is the only one that matters here.

app-df-corretto demo:df-amazoncorretto 21.0.13.1
app-jib        demo:jib               21.0.13
app-flag       demo:stale             21.0.13.0.3
app-default    demo:default           21.0.13.1
app-stale      demo:stale             21.0.13.0.3

Three of the five still need work. Note that app-flag shows the vulnerable build even though it carries the stopgap, because the banner reports the JVM, not its flags, so pair the list with the jcmd check for anything you mitigated. The loop also depends on the first log lines still being there, and a long-running container with rotated logs prints nothing, so treat a missing line as unknown rather than fixed.

What if the app runs as a jar on a server?

Then the JDK on the server is the one to patch, and the operating system update fixes it where one exists, because java -jar runs whatever java the host resolves. On our Ubuntu 24.04 host the candidate was the fixed build from USN-9156-1:

apt-cache policy openjdk-21-jre-headless | head -3

Installed and candidate match, so there is nothing left to upgrade on this host. A host where the candidate is newer than the installed version still needs the upgrade, and a restart before that upgrade changes nothing.

openjdk-21-jre-headless:
  Installed: 21.0.13.1+2-1~24.04.1
  Candidate: 21.0.13.1+2-1~24.04.1

The jar we started with java -jar picked it up, and jcmd against the live process confirms the build it is really running:

jcmd $(pgrep -f '^java -jar target/demo') VM.version | sed -n 2,3p

The running JVM is the patched Ubuntu build. We checked the live process rather than java -version in a shell, because a jar started before the upgrade would still report the old build here.

OpenJDK 64-Bit Server VM version 21.0.13.1+2-1-24.04.1-Ubuntu
JDK 21.0.13.1

A jar that was already running when the package updated keeps the old JVM until you restart it. Ubuntu and RHEL have fixed packages, as our Ubuntu Java4Shell patch guide shows, but Debian stable had none when we checked, so a Debian server needs the flag or a fixed vendor JDK, which our Debian Java4Shell guide covers.

What should you check before closing the ticket?

A Spring Boot service is done when every deployed copy runs a fixed JVM or carries a flag you have verified. Work through each service in this order:

  1. The startup banner of every running instance reports 17.0.21.1, 21.0.13.1, 25.0.5.1 or 27.0.1.1 or later.
  2. Buildpack builds pulled the current builder and logged Liberica buildpack 11.10.6 or later.
  3. Jib and Dockerfile builds no longer use an unfixed eclipse-temurin base.
  4. Every instance still on an older JVM shows UseBASE64Intrinsics = false from jcmd.
  5. Jars on servers were restarted after the OS package update.

If you are also mapping what else in your Java stack needs the same treatment, the Java4Shell hub tracks which distributions and base images have shipped fixed builds so far.

Keep reading

Java4Shell (CVE-2026-114938): Find and Patch Vulnerable JVMs Security Java4Shell (CVE-2026-114938): Find and Patch Vulnerable JVMs UFW Firewall Commands with Examples on Ubuntu 26.04 / 24.04 Security UFW Firewall Commands with Examples on Ubuntu 26.04 / 24.04 nginx HTTP/2 RCE CVE-2026-123007: Check, Disable HTTP/2, Patch Security nginx HTTP/2 RCE CVE-2026-123007: Check, Disable HTTP/2, Patch GL.iNet Security Notice: Check Your Router for Malware and Update Networking GL.iNet Security Notice: Check Your Router for Malware and Update Install LocalAI on Linux: Docker, Binary and GPU Setup AI Install LocalAI on Linux: Docker, Binary and GPU Setup Troubleshoot SELinux on Rocky Linux 10 / AlmaLinux 10 / RHEL 10 AlmaLinux Troubleshoot SELinux on Rocky Linux 10 / AlmaLinux 10 / RHEL 10

Leave a Comment

Press ESC to close