Containers

Patch Java4Shell (CVE-2026-114938) in Keycloak: Docker, ZIP and Operator

Your users hit Keycloak before they log in to anything else, and that’s exactly the request path Java4Shell needs. Keycloak decodes Base64 values from requests that arrive before authentication, and the researchers who found CVE-2026-114938 report a pre-auth remote code execution chain against it. If your Keycloak JVM runs an unpatched OpenJDK 17, 21 or 25 build on a CPU with AVX-512 VBMI, the login page itself is the exposure.

Original content from computingforgeeks.com - post 191993

A rebuilt 26.8 image is out, and a one-flag stopgap covers every version that can’t take it yet. Below, we check which Keycloak builds carry the fixed JDK, upgrade a Docker Compose deployment without losing its database, put the flag on images and ZIP installs that can’t move yet, and roll both changes through the Keycloak Operator. The Java4Shell CVE-2026-114938 overview covers the bug itself. We confirmed every step below working on a Google Cloud c3 instance with Docker and a kind cluster on 19 November 2026.

Find Keycloak builds with the fix

Keycloak’s container image bundles its own Red Hat OpenJDK, so the patch arrives as a rebuilt image, not as a new Keycloak release. On 19 November the project rebuilt 26.8.2 on Red Hat OpenJDK 21.0.13.1 and moved the latest, 26.8 and 26.8.2 tags onto it, per the Keycloak advisory. We read the runtime inside each image with java -version rather than trusting the tag:

Image or installJava runtime insideStatus on 19 Nov 2026
keycloak:26.8.2-3 (also 26.8.2, 26.8, latest)Red_Hat-21.0.13.1.2-1Fixed
keycloak:26.8.2-2 (also 26.8.2-1 and 26.8.2-0)Red_Hat-21.0.13.0.9-1Vulnerable
keycloak:26.7Red_Hat-21.0.12.1.1-1Vulnerable, not rebuilt
keycloak:26.6Red_Hat-21.0.11.0.10-1Vulnerable, not rebuilt
keycloak-operator:26.8.2Red_Hat-25.0.5.1.2-1Fixed (rebuilt the same morning)
Keycloak ZIP or TAR.GZWhatever JDK the host runsPatch the host JDK
Red Hat build of Keycloak (rhbk/keycloak-rhel9)Red Hat OpenJDKStill listed as affected by Red Hat

Two rows in that table catch people out. The 26.7 and 26.6 tags were never rebuilt, so a deployment pinned to an older minor line stays vulnerable however often you pull it, and its only way to the fix is the 26.8 upgrade or the flag. The ZIP distribution ships no JVM at all, which makes it the easy case. You patch the JDK the host already runs. Red Hat’s own build of Keycloak follows Red Hat’s errata, and its CSAF data still listed rhbk/keycloak-rhel9 as affected when we checked, so treat it like the 26.7 line for now.

Fixed builds are 17.0.21.1, 21.0.13.1 and 25.0.5.1 or later. A .1 in the fourth version field is not enough on its own: the 21.0.12.1 build in 26.7 is still vulnerable. Anything at or below 21.0.13.0.x, 17.0.21.0.x or 25.0.5.0.x is in the affected range, and Java 17 is affected from 17.0.6 onward.

Check the CPU under each Keycloak node

Only x86-64 CPUs that expose AVX-512 VBMI get the vulnerable decoder, so the first check runs on the host, not in the container. On Kubernetes, run it on every node that can schedule a Keycloak pod, including the ones a rolling update might land on:

grep -oE "(avx512f|avx512bw|avx512vbmi|bmi2)" /proc/cpuinfo | sort -u

Our c3 instance (Intel Xeon Platinum 8481C, Sapphire Rapids) printed all four features, which is the worst case:

avx512bw
avx512f
avx512vbmi
bmi2

Fewer than four lines means the JVM on that host never generates the vulnerable stub, and ARM64 nodes are out of scope entirely. We’d still patch those nodes on the normal schedule, because a pod that moves from an ARM node to a new Intel or AMD Zen 4 node takes the exposure with it the moment it lands.

Read each running Keycloak JVM

A tag in your compose file tells you what you asked for, while the live JVM tells you what is actually running. The official image ships jcmd, and Keycloak runs as PID 1 inside its container, so one loop on each Docker host asks every Keycloak container for its build:

for c in $(sudo docker ps --format "{{.Names}} {{.Image}}" | grep "keycloak/keycloak:" | cut -d" " -f1); do echo "$c $(sudo docker inspect -f "{{.Config.Image}}" $c) $(sudo docker exec $c jcmd 1 VM.version | sed -n 2p)"; done

On our host, one container ran the pre-fix image and one the rebuilt one, and the build string separates them at a glance:

kc-old-test quay.io/keycloak/keycloak:26.8.2-2 OpenJDK 64-Bit Server VM version 21.0.13+9-LTS
keycloak-keycloak-1 quay.io/keycloak/keycloak:26.8.2-3 OpenJDK 64-Bit Server VM version 21.0.13.1+2-LTS

21.0.13+9 is the vulnerable build and 21.0.13.1+2 the fixed one. We use jcmd here instead of docker exec ... java -version on purpose: java -version starts a second JVM from the image, which tells you what a restart would run, not what’s serving logins right now. On Kubernetes, the same question goes through kubectl exec, and the main class name finds the process for you:

kubectl -n keycloak exec example-kc-0 -c keycloak -- jcmd io.quarkus.bootstrap.runner.QuarkusEntryPoint VM.version

Our Operator-managed pod answered with the fixed build:

1:
OpenJDK 64-Bit Server VM version 21.0.13.1+2-LTS
JDK 21.0.13.1

Upgrade a Docker Compose deployment to 26.8.2-3

Most self-hosted Keycloak installs run on Compose, and this is the path we’d take first, because it removes the bug instead of working around it. Our test deployment ran Keycloak against Postgres 17, with the image tag kept in .env so the upgrade is a one-line change. If you’re still building this setup, our guide to running Keycloak in Docker or Podman with SSL covers the TLS side. Open the compose file:

vim compose.yaml

We ran exactly this file, with the tag, passwords and an optional JAVA_OPTS_APPEND coming from .env.

services:
  postgres:
    image: postgres:17
    environment:
      POSTGRES_DB: keycloak
      POSTGRES_USER: keycloak
      POSTGRES_PASSWORD: ${KC_DB_PASSWORD}
    volumes:
      - pgdata:/var/lib/postgresql/data

  keycloak:
    image: quay.io/keycloak/keycloak:${KC_TAG}
    command: start --http-enabled=true --hostname-strict=false
    environment:
      KC_DB: postgres
      KC_DB_URL: jdbc:postgresql://postgres:5432/keycloak
      KC_DB_USERNAME: keycloak
      KC_DB_PASSWORD: ${KC_DB_PASSWORD}
      KC_BOOTSTRAP_ADMIN_USERNAME: admin
      KC_BOOTSTRAP_ADMIN_PASSWORD: ${KC_ADMIN_PASSWORD}
      KC_HEALTH_ENABLED: "true"
      JAVA_OPTS_APPEND: ${JAVA_OPTS_APPEND:-}
    ports:
      - "8080:8080"
      - "9000:9000"
    depends_on:
      - postgres

volumes:
  pgdata:

Before the upgrade we created a realm called demo with one user, alice, so we could prove the database came through untouched. Then we moved the tag to the rebuilt image, pulled it and recreated only the Keycloak container:

sed -i "s/^KC_TAG=.*/KC_TAG=26.8.2-3/" .env
sudo docker compose pull keycloak -q
sudo docker compose up -d keycloak

Compose recreates the container on the new image and leaves Postgres running:

 Container keycloak-keycloak-1  Recreated
 Container keycloak-keycloak-1  Starting
 Container keycloak-keycloak-1  Started

The explicit pull matters if you track the moving 26.8.2 or 26.8 tag rather than 26.8.2-3. Compose’s default pull policy only pulls an image that is missing, so a host that pulled 26.8.2 last week keeps running the old digest through every up -d until you pull. Pinning the full 26.8.2-3 tag avoids that ambiguity, which is why we’d pin it. Once the readiness check passes, ask the new JVM for its build:

curl -s localhost:9000/health/ready | jq -r .status
sudo docker compose exec keycloak jcmd 1 VM.version

Both answers should change: the health endpoint reports UP and the running JVM is now the fixed build.

UP
1:
OpenJDK 64-Bit Server VM version 21.0.13.1+2-LTS
JDK 21.0.13.1

Our realm and user from the old image were still there, read back through the admin CLI inside the new container, with the original creation timestamp:

sudo docker compose exec -T keycloak /opt/keycloak/bin/kcadm.sh get users -r demo --fields username,createdTimestamp --server http://localhost:8080 --realm master --user admin --password ChangeMe-AdminPass1

One login line, then the user that predates the upgrade:

Logging into http://localhost:8080 as user admin of realm master
[ {
  "username" : "alice",
  "createdTimestamp" : 1795078815618
} ]

26.8.2-2 to 26.8.2-3 is the same Keycloak release on a new base, so there is no schema migration, and the outage is one container restart: ours reported ready again within a minute. Coming from 26.6 or 26.7 is a real Keycloak upgrade with database migrations, so take a Postgres dump first and read the upgrade notes for the versions you skip.

Set the stopgap on older images

When a deployment is stuck on 26.7, 26.6 or the Red Hat build, turn off the vulnerable path instead. -XX:-UseBASE64Intrinsics makes the JVM use its portable Base64 decoder, and Keycloak’s start script appends anything in JAVA_OPTS_APPEND to its own JVM options. In our Compose file that’s one line in .env, which is how we ran the vulnerable 26.8.2-2 image before the upgrade:

KC_TAG=26.8.2-2
KC_DB_PASSWORD=ChangeMe-DbPass1
KC_ADMIN_PASSWORD=ChangeMe-AdminPass1
JAVA_OPTS_APPEND=-XX:-UseBASE64Intrinsics

If your JAVA_OPTS_APPEND already carries other options, add the flag to the existing value instead of replacing it. After sudo docker compose up -d, the start log prints Appending additional Java properties to JAVA_OPTS. That line only proves the script saw the variable, so check the flag inside the live JVM:

sudo docker compose exec keycloak jcmd 1 VM.version
sudo docker compose exec keycloak jcmd 1 VM.flags -all | grep UseBASE64Intrinsics

Here the vulnerable build is still running, but the intrinsic is off and the source column says the command line put it there.

1:
OpenJDK 64-Bit Server VM version 21.0.13+9-LTS
JDK 21.0.13
     bool UseBASE64Intrinsics                      = false                                     {product} {command line}

A true or a {default} source means the variable never reached that JVM, usually because the container was not recreated. Calif also lists -XX:UseAVX=2 as an alternative, and it worked in our tests, but it switches off every AVX-512 optimization in the JVM and stops an ARM64 JVM from starting at all. In a multi-arch cluster that is an outage waiting for the first ARM node, so we’d stay with the Base64 flag.

Patch a ZIP install through the host JDK

Neither the ZIP nor the TAR.GZ distribution contains a Java runtime, so a bare-metal Keycloak is exactly as patched as the JDK its service starts. That is often not the JDK in your shell’s PATH, so start from the running process. As the Keycloak service user, list the JVMs and resolve the main one back to its binary:

sudo -u keycloak jcmd -l
sudo readlink /proc/14048/exe
sudo -u keycloak jcmd 14048 VM.version

Replace 14048 with the PID next to QuarkusEntryPoint. Our systemd service on Ubuntu 24.04 ran the distribution’s OpenJDK 21, already on the patched build:

14048 io.quarkus.bootstrap.runner.QuarkusEntryPoint start-dev
14240 jdk.jcmd/sun.tools.jcmd.JCmd -l
/usr/lib/jvm/java-21-openjdk-amd64/bin/java
14048:
OpenJDK 64-Bit Server VM version 21.0.13.1+2-1-24.04.1-Ubuntu
JDK 21.0.13.1

Ubuntu shipped that build on 18 November, so on Ubuntu the patch is an apt upgrade of openjdk-21-jdk-headless or openjdk-21-jre-headless plus a service restart (jcmd, which the checks here use, ships only in openjdk-21-jdk-headless, so install it on a JRE-only host), and our Ubuntu Java4Shell patch guide has the package versions per release. A host whose JDK has no fix yet gets the flag through a systemd drop-in, which survives package upgrades of the unit file:

sudo mkdir -p /etc/systemd/system/keycloak.service.d
printf "[Service]\nEnvironment=\"JAVA_OPTS_APPEND=-XX:-UseBASE64Intrinsics\"\n" | sudo tee /etc/systemd/system/keycloak.service.d/java4shell.conf
sudo systemctl daemon-reload
sudo systemctl restart keycloak

Then confirm the flag in the JVM the service actually started, using the PID that jcmd -l lists after the restart:

sudo -u keycloak jcmd 14048 VM.flags -all | grep -F UseBASE64Intrinsics

Look for false with {command line} as the source.

     bool UseBASE64Intrinsics                      = false                                     {product} {command line}

Run jcmd as the service user or as root. From any other account the attach fails with well-known file /tmp/.java_pid14048 is not secure: file should be owned by the current user, which looks like a broken JVM but is only the attach API refusing a JVM owned by someone else.

Roll the fix through the Keycloak Operator

The Operator decides which Keycloak image your pods run, through its RELATED_IMAGE_KEYCLOAK setting, and Operator 26.8.2 points at quay.io/keycloak/keycloak:26.8.2. That is the moving tag, so the question is whether a node that pulled it before 19 November reuses its cached copy. We tested the worst case by loading the pre-fix 26.8.2 image onto the kind node before creating the Keycloak resource, then asked the StatefulSet how it pulls:

kubectl -n keycloak get sts example-kc -o jsonpath="{.spec.template.spec.containers[0].image} {.spec.template.spec.containers[0].imagePullPolicy}{\"\n\"}"

It reports a pull policy of Always.

quay.io/keycloak/keycloak:26.8.2 Always

Because the Operator sets that pull policy, a stale cached image on the node does not matter: the pod came up on the fixed digest and reported JDK 21.0.13.1, the output shown earlier. What does matter is that pods started before the rebuild keep their old image until they restart, and nothing restarts them for you. Adding the flag through the custom resource covers both jobs at once, because changing spec.env makes the Operator replace every pod. We kept the change in a small merge patch:

vim keycloak-cr-env-patch.yaml

Add the variable under spec.env:

spec:
  env:
    - name: JAVA_OPTS_APPEND
      value: "-XX:-UseBASE64Intrinsics"

Apply it to the existing resource, wait for the rollout, and check the flag in the replacement pod:

kubectl -n keycloak patch keycloak example-kc --type merge --patch-file keycloak-cr-env-patch.yaml
kubectl -n keycloak rollout status sts/example-kc --timeout=300s
kubectl -n keycloak exec example-kc-0 -c keycloak -- jcmd io.quarkus.bootstrap.runner.QuarkusEntryPoint VM.flags -all | grep -F UseBASE64Intrinsics

The pod was replaced (its UID changed) and the new JVM runs with the intrinsic off:

     bool UseBASE64Intrinsics                      = false                                     {product} {command line}

On a running cluster, we’d do it in this order, so the Operator is patched before it starts replacing Keycloak pods:

  1. Restart the Operator Deployment so it runs the rebuilt image.
  2. Patch spec.env on each Keycloak resource, which replaces its pods on the fixed image with the flag set.
  3. Wait for rollout status, then run the jcmd checks against every pod, not only example-kc-0.

A merge patch on spec.env replaces the whole list, so if your resource already sets environment variables, put them in the patch file too or edit the resource instead. The Operator itself is a second JVM, but its 26.8.2 image was rebuilt on Red Hat OpenJDK 25.0.5.1 with imagePullPolicy: Always, so restarting it with kubectl -n keycloak rollout restart deployment/keycloak-operator pulls the rebuilt image. Keycloak’s advisory gives the JDK_JAVA_OPTIONS setting for Operator installs that cannot restart onto the new image. The full Operator and CloudNativePG setup is in our guide to deploying Keycloak on Kubernetes with the Operator.

One snag hit us on a fresh cluster. Installing only the keycloaks and keycloakrealmimports CRDs, the two that older Operator releases needed, left Operator 26.8.2 in CrashLoopBackOff with Couldn't start informer for keycloaksamlclients.k8s.keycloak.org/v2alpha1 resources. The 26.8.2 manifests also include the keycloakoidcclients and keycloaksamlclients CRDs, and the Operator started once all four were applied.

Trust the build string, not the test

Calif published a bounded self-test with its Java4Shell write-up that prints REPRODUCED on an affected JDK, and we ran it unchanged inside the Keycloak images. The first run on the vulnerable 26.8.2-2 image printed NOT REPRODUCED, exactly like the fixed image did. Ten more runs reproduced the overwrite only four times, because the test only bites once the JIT has compiled the decoder, and whether that happens before the test input arrives depends on timing.

Once the decoder was compiled first, the result was consistent. The vulnerable image reproduced every time, while the fixed 26.8.2-3 image, the vulnerable image with -XX:-UseBASE64Intrinsics and the vulnerable image with -XX:UseAVX=2 never did. The test is useful as a positive signal, but a single pass proves nothing, which is the wrong property for a change record. The evidence we’d keep for each Keycloak node is these three checks:

  1. The live JVM’s build from jcmd VM.version: 21.0.13.1, 17.0.21.1 or 25.0.5.1 or later means fixed.
  2. On anything older, UseBASE64Intrinsics = false from jcmd VM.flags, sourced from {command line} or {environment}.
  3. A host CPU check, so you know which nodes would turn a missing flag into real exposure.

With those three per node, a Keycloak cluster is either on the rebuilt image or carrying the flag, and you can show which. If Keycloak sits behind other Java services, the same checks apply to them, and the Java4Shell hub tracks which distributions and 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 Convert unprivileged container in Proxmox to privileged Containers Convert unprivileged container in Proxmox to privileged

Leave a Comment

Press ESC to close