Containers

Patch Java4Shell CVE-2026-114938 on Alpine Linux and Java Images

Rebuild a Java image on alpine:3.24 or alpine:3.23 today and apk hands you a JDK with the Java4Shell fix. Rebuild the same Dockerfile on alpine:3.22 and you still get a build that CVE-2026-114938 can corrupt. The eclipse-temurin Alpine tags now carry the fixed JDK after a rebuild on 20 November, but the arm64 builds of the Ubuntu-based 17 and 21 tags do not. To make it worse, apk upgrade inside a Temurin image changes nothing, and Trivy and Grype both reported the vulnerable images as clean.

Original content from computingforgeeks.com - post 191839

Below, we find every Java runtime in your Alpine containers, patch the apk-installed OpenJDK on 3.24 and 3.23, pull the fix onto 3.22, and put a stopgap on images that have no fixed build yet. The Java4Shell CVE-2026-114938 overview explains the bug itself. We ran all of it on 18 November 2026 on a Google Cloud c3 instance with Docker 29, where every container saw the AVX-512 flags the bug needs, and re-pulled the Temurin images on 20 November 2026 on a c3 and an arm64 c4a instance.

Fixed OpenJDK packages per Alpine branch

Alpine builds OpenJDK per branch, so the fix status depends on the release your image starts from, not on the Java version. We read these versions with apk search inside each official alpine image and checked them against the Alpine security tracker and the release support dates:

Branch (supported until)openjdk17openjdk21openjdk25Status on 18 Nov 2026
3.24 (2028-06-01)17.0.21.1_p2-r021.0.13.1_p2-r025.0.5.1_p2-r0Fixed
3.23 (2027-11-01)17.0.21.1_p2-r021.0.13.1_p2-r025.0.5.1_p2-r0Fixed (reached the mirrors on 18 Nov)
3.22 (2027-05-01)17.0.19_p10-r021.0.11_p10-r0not packagedVulnerable; no fix committed
3.21End of support on 1 November 2026Move to 3.24

The fixed builds carry a .1 in the fourth version field, matching the upstream jdk-17.0.21.1, jdk-21.0.13.1 and jdk-25.0.5.1 releases. No stable branch packages OpenJDK 27, and openjdk8 and openjdk11 are not affected. The 3.22 row is the uncomfortable one, because its Java 17 and 21 packages are already older than the October update, so a 3.22 image is behind on more than this one CVE. The package browser at pkgs.alpinelinux.org lagged the mirrors on the day 3.23 shipped, so trust apk search inside the container over the website.

Images that bundle their own JDK do not follow this table at all. These are the common Alpine Java images as we found them on 18 November, with the Temurin rows re-checked on 20 November. Each runtime was read from java -version inside the image rather than from the tag:

ImageAlpine baseJava runtime insideStatus
alpine:3.24 + apk openjdk3.24.421.0.13.1+2-alpine-r0Fixed
amazoncorretto:17, 21, 25-alpine3.24.4Corretto 17.0.21.1.2, 21.0.13.1.2, 25.0.5.1.2Fixed (rebuilt 17 Nov)
eclipse-temurin:17-jre-alpine3.24Temurin 17.0.21.1+2 (amd64 only, no arm64 image)Fixed (rebuilt 20 Nov)
eclipse-temurin:21-jre-alpine3.24.4Temurin 21.0.13.1+2 on amd64 and arm64Fixed (rebuilt 20 Nov)
eclipse-temurin:25-jre-alpine, 27-jre-alpine3.24Temurin 25.0.5.1+2 and 27.0.1.1+4 on amd64 and arm64Fixed (rebuilt 20 Nov)
eclipse-temurin:17-jre, 21-jre, 21-jdkUbuntu, not Alpineamd64: 17.0.21.1+2, 21.0.13.1+2. arm64: 17.0.21+9, 21.0.13+9Fixed on amd64, pre-fix build on arm64

Adoptium has named the Temurin builds that carry the fix (17.0.21.1+2, 21.0.13.1+2, 25.0.5.1+2 and 27.0.1.1+4). The Dockerfile update that moves the images to them merged on 20 November, and Docker Hub pushed the rebuilt tags from 18:04 UTC that day. Its readiness report still lists arm64 as pending an upstream binary for the Ubuntu and UBI variants of JDK 17 and 21. Those tags therefore kept their 12 November arm64 builds while the amd64 side moved, and the 25 tags are fixed on both.

1. Check the CPU your containers run on

Java4Shell only bites on x86-64 CPUs with AVX-512 VBMI, where HotSpot swaps in its hand-written Base64 decoder. A container reads /proc/cpuinfo from the host, so you can run the check from a plain Alpine container and see exactly what a Java process inside it would see. We did that on the lab host.

docker run --rm alpine:3.24 sh -c 'grep -o -w -E "avx512f|avx512bw|avx512vbmi|bmi2" /proc/cpuinfo | sort -u'

All four flags came back on the c3 instance, which is an Intel Xeon Platinum 8481C. That puts every Java container on this host in the exposed group.

avx512bw
avx512f
avx512vbmi
bmi2

An empty result lowers the urgency for that node, but it does not settle the question for the image. Kubernetes and ECS schedule the same image onto whatever node has room, and the Red Hat CVE entry lists Intel Ice Lake through Granite Rapids and AMD Zen 4 to 6 as CPUs with the instruction set. Alpine images running on arm64 are not known to be affected.

To confirm the JVM itself uses the AVX-512 path, ask it for its final flags. You want this from the exact image your service runs, and we did it on an alpine:3.23 container earlier that day, while 3.23 still shipped the vulnerable openjdk21.

java -XX:+PrintFlagsFinal -version 2>/dev/null | grep -E "UseBASE64Intrinsics|UseAVX "

UseAVX = 3 means the AVX-512 code paths are on, and UseBASE64Intrinsics = true is the default the bug needs. The fixed build prints exactly the same two lines, because the fix corrects the decoder rather than turning it off, so read the version to tell them apart.

      int UseAVX                                   = 3                                    {ARCH product} {default}
     bool UseBASE64Intrinsics                      = true                                      {product} {default}

Those two lines came from the vulnerable 21.0.13.0.3 build, so on its own this check tells you the CPU path is live, not whether the JDK is patched.

2. Find every Java runtime in your containers

Image tags are a poor inventory here. Corretto tags use three version fields for four-field builds, and the floating Temurin tags keep their names across the fix, so we asked each running container for its runtime instead. This loop skips containers that have no java on the PATH, so you can run it on a busy host without filtering first.

for c in $(docker ps -q); do
  name=$(docker inspect -f "{{.Name}}" "$c" | cut -c2-)
  ver=$(docker exec "$c" sh -c "command -v java >/dev/null && java -version 2>&1 | head -1" 2>/dev/null)
  [ -n "$ver" ] && printf "%-32s %s\n" "$name" "$ver"
done

Our lab host ran one container from each image family plus an nginx container, which the loop correctly left out, and your output will look the same with more rows. Two of the four Java containers were still vulnerable, and one of them sits on a 3.24 base.

j4s-apk-3-24                     openjdk version "21.0.13.1" 2026-11-17
j4s-apk-3-23                     openjdk version "21.0.13.0.3" 2026-10-24
amazoncorretto-21-alpine         openjdk version "21.0.13.1" 2026-11-17 LTS
eclipse-temurin-21-jre-alpine    openjdk version "21.0.13" 2026-10-20 LTS

Read the fourth field: 21.0.13.1 is fixed, while 21.0.13.0.3 and the plain Temurin 21.0.13 are both on the vulnerable side. The j4s-apk-3-23 container came from an image we built earlier that day, before the 3.23 packages reached the mirrors, so a fixed branch does nothing for images built earlier. The Temurin line, from the 18 November pull before Adoptium rebuilt the image, is the one teams will misread, because its Alpine base is 3.24 and it looks patched at a glance. For images that are not running, swap the docker exec for docker run --rm --entrypoint java <image> -version, which is how we built the image table above.

3. Rebuild apk-installed OpenJDK on Alpine 3.24 and 3.23

On 3.24 and 3.23, patching is a plain rebuild, as long as the build does not reuse an old layer. A cached RUN apk add layer keeps whatever JDK it fetched the first time, so force a fresh base image and a fresh package fetch. This is the whole Dockerfile we used.

FROM alpine:3.23
RUN apk add --no-cache openjdk21-jre-headless

Build it with --pull so Docker checks for a newer alpine:3.23, and with --no-cache so the apk add line runs again.

docker build --pull --no-cache -t orders-api:fixed .
docker run --rm orders-api:fixed java -version

The new image reports the fixed Alpine build. Did the apk add line really run again? The build number answers that, because a cached layer would still print 21.0.13.0.3. Swap openjdk21 for openjdk17 or openjdk25 and the result is the same pattern, which we also checked on 3.24 (17.0.21.1 and 25.0.5.1).

openjdk version "21.0.13.1" 2026-11-17
OpenJDK Runtime Environment (build 21.0.13.1+2-alpine-r0)
OpenJDK 64-Bit Server VM (build 21.0.13.1+2-alpine-r0, mixed mode, sharing)

An Alpine VM or a long-lived container takes the fix with apk update and apk upgrade, the same way as any other package. We ran that inside the 3.23 image we had built earlier that day on the vulnerable build:

apk update
apk upgrade
java -version

apk pulled the fixed JDK along with a pending zlib update, and the runtime reported the fixed build straight away. Restart the Java service afterwards, because a running JVM keeps the old library loaded until it starts again.

(1/2) Upgrading zlib (1.3.2-r1 -> 1.4-r0)
(2/2) Upgrading openjdk21-jre-headless (21.0.13.0.3_p1-r0 -> 21.0.13.1_p2-r0)
Executing java-common-1.0-r1.trigger
OK: 198.7 MiB in 24 packages
openjdk version "21.0.13.1" 2026-11-17
OpenJDK Runtime Environment (build 21.0.13.1+2-alpine-r0)
OpenJDK 64-Bit Server VM (build 21.0.13.1+2-alpine-r0, mixed mode, sharing)

For a container, the in-place upgrade is a diagnosis, not the fix. The next container started from the old image comes back vulnerable, so rebuild the image as above and redeploy.

4. Pull the fix onto Alpine 3.22

Alpine 3.22 has no fixed build and no fix committed, so if you can move a 3.22 image to 3.24, do that first, because it is the cleanest fix. On a running 3.22 system that means pointing the repositories at the new branch and upgrading everything, which we did in an alpine:3.22 container with openjdk21 installed.

sed -i 's/v3.22/v3.24/g' /etc/apk/repositories
apk update
apk upgrade --available
cat /etc/alpine-release

apk replaced or upgraded 22 packages, the JDK last, and the system came up as 3.24.4 with the fixed Java. In a Dockerfile the same move is simply changing FROM alpine:3.22 to FROM alpine:3.24.

(22/22) Upgrading openjdk21-jre-headless (21.0.11_p10-r0 -> 21.0.13.1_p2-r0)
Executing busybox-1.37.0-r31.trigger
Executing java-common-1.0-r2.trigger
Executing ca-certificates-20261020-r0.trigger
OK: 198.7 MiB in 24 packages
3.24.4

When a full branch upgrade has to wait, you can take only the JDK from 3.24 with a tagged repository. The Alpine wiki warns that mixing packages from different branches is not officially supported, so treat it as a bridge until 3.22 gets its own fixed build or the image moves to 3.24. Add the 3.24 community repository under a tag, then install every openjdk package you already have from it:

echo "@v324 https://dl-cdn.alpinelinux.org/alpine/v3.24/community" >> /etc/apk/repositories
apk update
apk add $(apk info | grep ^openjdk21 | sed 's/$/@v324/')

We ran that on alpine:3.22 with the full openjdk21 JDK installed, and apk moved all four subpackages from 21.0.11 straight to the fixed build. It needed no other package from 3.24, which is why this bridge is reasonable for a JDK even though mixing branches is unsupported:

(1/4) Upgrading openjdk21-jre-headless@v324 (21.0.11_p10-r0 -> 21.0.13.1_p2-r0)
(2/4) Upgrading openjdk21-jre@v324 (21.0.11_p10-r0 -> 21.0.13.1_p2-r0)
(3/4) Upgrading openjdk21-jmods@v324 (21.0.11_p10-r0 -> 21.0.13.1_p2-r0)
(4/4) Upgrading openjdk21-jdk@v324 (21.0.11_p10-r0 -> 21.0.13.1_p2-r0)
Executing java-common-1.0-r0.trigger
OK: 302 MiB in 45 packages

The apk info | grep part matters more than it looks, and the snag we hit at the end of this guide shows why. Taking the bridge down needs the same care, because a tagged package stays pinned to its tag. Delete only the repository line and apk upgrade refuses to run:

WARNING: The repository tag for world dependency 'openjdk21-jre-headless@v324' does not exist
ERROR: Not continuing with upgrade due to missing repository tags.

Once your branch ships its own fixed build, take the tag off the packages first, then remove the repository line and upgrade. We ran this on a bridged 3.23 container after the 3.23 packages landed:

apk add $(apk info | grep ^openjdk21)
sed -i '/^@v324/d' /etc/apk/repositories
apk update
apk upgrade
apk policy openjdk21-jre-headless

The upgrade exited 0, /etc/apk/world lost its @v324 tags, and the policy shows the package coming from the branch’s own repository again:

openjdk21-jre-headless policy:
  21.0.13.1_p2-r0:
    lib/apk/db/installed
    https://dl-cdn.alpinelinux.org/alpine/v3.23/community

Put the removal on the calendar the day you add the bridge. A forgotten tag keeps that JDK pinned to the 3.24 repository even after your own branch ships a newer build, which is how the Alpine wiki describes a tagged package.

5. Re-pull the rebuilt eclipse-temurin images

Temurin images ship the JDK in /opt/java/openjdk, outside apk, so the Alpine package manager cannot patch it. On 18 November an apk upgrade inside eclipse-temurin:21-jre-alpine ran without a word and left the runtime on 21.0.13+9. The fix only reaches you through a new image, so pull every Temurin tag you use with --pull always and read the build from java -version. This loop is what we ran on both lab instances on 20 November, prefixed with sudo there because the lab user was not in the docker group:

for t in 17-jre 21-jre 21-jdk 25-jre 17-jre-alpine 21-jre-alpine 25-jre-alpine 27-jre-alpine; do
  out=$(docker run --rm --pull always -q eclipse-temurin:$t java -version 2>&1 | sed -n 2p)
  printf "%-16s %s\n" "$t" "${out:-<no image for this arch>}"
done

On the x86 c3 instance every tag came back on a fixed build, Alpine and Ubuntu alike:

eclipse-temurin tags on amd64 reporting fixed Temurin 17.0.21.1+2, 21.0.13.1+2, 25.0.5.1+2 and 27.0.1.1+4 builds

The arm64 c4a instance pulled the same tag names and got a different answer for the Ubuntu-based 17 and 21 images. They still run the October builds. 17-jre-alpine has no arm64 image at all, so Java 17 on arm64 has no fixed Temurin tag yet:

eclipse-temurin tags on arm64: 17-jre and 21-jre still on 17.0.21+9 and 21.0.13+9, alpine and 25 tags fixed

On amd64 the fix is now a plain rebuild with docker build --pull --no-cache, the same as in step 3, so the old base layer is not reused. After that, check the image that ships rather than the tag name. We ran this against the freshly pulled Alpine tag on both instances:

docker run --rm eclipse-temurin:21-jre-alpine sh -c 'readlink -f $(which java); echo $JAVA_VERSION; cat /etc/alpine-release; java -version 2>&1 | head -1'

Both CPUs printed the same four lines. The JAVA_VERSION baked into the image now names the fixed build, and the base is still Alpine 3.24.4:

eclipse-temurin 21-jre-alpine image showing JAVA_VERSION jdk-21.0.13.1+2 on Alpine 3.24.4

If JAVA_VERSION still reads jdk-21.0.13+9, Docker served a cached copy of the old tag, so pull it again before you build.

Check the architecture on Graviton, Ampere and Apple Silicon hosts

One tag name now maps to a fixed build on x86 and an old one on arm64, so confirm what a running container really is. docker image inspect reports the platform of the image behind the container, and docker exec asks the JVM inside it. We started a throwaway container named orders-api from eclipse-temurin:21-jre to test, so swap in your own container name:

docker run -d --name orders-api eclipse-temurin:21-jre tail -f /dev/null
docker inspect --format '{{.Image}}' orders-api | xargs docker image inspect --format '{{.Os}}/{{.Architecture}}'
docker exec orders-api java -version

On the c4a instance, a container started from eclipse-temurin:21-jre reported the October build:

Running eclipse-temurin 21-jre container on linux/arm64 reporting the pre-fix Temurin 21.0.13+9 build

The same commands on the c3 instance printed linux/amd64 and the fixed Temurin-21.0.13.1+2 build from the same tag name:

Running eclipse-temurin 21-jre container on linux/amd64 reporting the fixed Temurin 21.0.13.1+2 build

Pinning a digest helps only if you pin the right one. docker image inspect --format '{{index .RepoDigests 0}}' gave the same 21-jre digest on both instances, because it is the multi-arch index, and that index still points arm64 at the old build. We ran both pins on the arm64 instance:

docker run --rm -q eclipse-temurin:21-jre-alpine@sha256:5d7689f47d670aca766b9503a70bccc2d73b4eb9221ae8f714ae958313c4ce70 java -version 2>&1 | sed -n 2p
docker run --rm -q eclipse-temurin:21-jre@sha256:d77e090ae1f6970c047b443c6f0a6c1358b0426d44432bb5a7753408cd43de0d java -version 2>&1 | sed -n 2p

The Alpine digest gives the fixed build on both CPUs, so it is a safe pin. The 21-jre digest stays vulnerable on arm64 even though it is fixed on amd64:

Digest pins on arm64: 21-jre-alpine digest gives Temurin 21.0.13.1+2, 21-jre digest still gives 21.0.13+9

Until Adoptium rebuilds the arm64 images, these are the options for 17-jre, 21-jre and 21-jdk on arm64:

  • Move Java 21 services to eclipse-temurin:21-jre-alpine, or pin the Alpine digest above.
  • Use the 25-jre or 25-jre-alpine tag if the app already runs on Java 25.
  • Switch the base to alpine:3.24 with apk openjdk from step 3. An Ubuntu 22.04 or newer base with OpenJDK from apt is also fixed, and the Ubuntu patch walkthrough lists the build to expect on each release.
  • For Java 17, re-run the loop until 17-jre reports 17.0.21.1+2 on arm64.

Java4Shell needs AVX-512 VBMI, so an arm64 host is not known to hit the bug itself. The arm64 images still carry the pre-fix JDK, though, and that fails version checks and policy gates. A mixed cluster also ends up running two builds under one tag name. Keep the flag from the next step for x86 images you cannot rebuild yet.

6. Set the stopgap flag in the image

Disabling the Base64 intrinsic removes the vulnerable code path, which is the interim mitigation in the Red Hat RHSB-2026-018 bulletin and in the Adoptium guidance. JAVA_TOOL_OPTIONS is read by every JVM at start, so one environment line covers the service without touching its entrypoint:

FROM eclipse-temurin:21-jre-alpine
ENV JAVA_TOOL_OPTIONS="-XX:-UseBASE64Intrinsics"

We built that image and asked the JVM for the final value of the flag. If your image already sets JAVA_TOOL_OPTIONS, append the flag to the existing value instead, because a second ENV line replaces the first:

docker build -t app:stopgap .
docker run --rm app:stopgap java -XX:+PrintFlagsFinal -version 2>&1 | grep -E "Picked up|UseBASE64Intrinsics"

The JVM announces the option and reports the intrinsic off, with the source column showing it came from the environment rather than a default. If you do not see the Picked up line, the variable never reached the JVM.

Picked up JAVA_TOOL_OPTIONS: -XX:-UseBASE64Intrinsics
     bool UseBASE64Intrinsics                      = false                                     {product} {environment}

The same variable works without a rebuild: docker run -e JAVA_TOOL_OPTIONS=-XX:-UseBASE64Intrinsics gave us the identical two lines on the stock Temurin image, and a Compose environment: entry or the env list of a pod sets the same variable. The flag slows Base64 work down, so remove it once the service runs on a fixed build.

7. Why Trivy and Grype show nothing yet

If your pipeline gates on a scanner, a clean scan is not evidence this week. We scanned four images with Trivy 0.76.2 and Grype 0.122.0 on their newest databases, built at 07:15 and 06:21 UTC on 18 November.

  • j4s-apk:3.23, built before the 3.23 fix, vulnerable
  • j4s-apk:3.24, fixed apk openjdk21
  • eclipse-temurin:21-jre-alpine, the 18 November pull, vulnerable
  • amazoncorretto:21-alpine, fixed

Neither tool reported CVE-2026-114938 on any of them, vulnerable or fixed, so a green scan stage told us nothing about which two images needed work.

The Alpine security database itself already lists the fixed openjdk17, openjdk21 and openjdk25 versions for both 3.23 and 3.24, so expect the apk-installed images to light up after a later database refresh. When they do, a vulnerable 3.23 image will show 21.0.13.1_p2-r0 as the fix, which a rebuild or apk upgrade now installs. The 3.22 database has no entry for this CVE at all, so a 3.22 image can keep scanning clean while it runs a vulnerable JDK. Until then, the java -version loop from step 2 is the check to trust.

What broke: a JDK split across two versions

Our first attempt at the bridge, on 3.23 before its own fixed build reached the mirrors, pinned only the package we thought mattered. On an alpine:3.23 container with the full openjdk21 JDK, we ran apk add openjdk21-jre-headless@v324, and apk upgraded that one package and nothing else.

(1/1) Upgrading openjdk21-jre-headless@v324 (21.0.13.0.3_p1-r0 -> 21.0.13.1_p2-r0)
Executing java-common-1.0-r1.trigger
OK: 302.2 MiB in 45 packages

apk raised no conflict, but openjdk21-jdk, openjdk21-jre and openjdk21-jmods all stayed on 21.0.13.0.3, so the box carried a JDK split across two builds. That is why the bridge command reads the installed list with apk info and pins every openjdk21 package at once. After any partial upgrade, list the packages and make sure they all share one version:

apk list -I | grep openjdk21

Every line should show the same 21.0.13.1_p2-r0 build. Corretto subpackages on Amazon Linux follow the same rule, and our Java4Shell patch guide for Amazon Linux covers that, along with the package manager quirks that hide the fix there. On Alpine, the short version is: rebuild or apk upgrade on 3.24 and 3.23, move 3.22 to 3.24 or bridge it with every openjdk package pinned, and re-pull the Temurin tags, checking the architecture on arm64 hosts.

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 How To Run Mayan EDMS in Docker Containers Containers How To Run Mayan EDMS in Docker Containers

Leave a Comment

Press ESC to close