Skip to content

fix(security): mitigate Java4Shell (CVE-2026-114938) in Keycloak and runtime: java - #132

Open
Teg79 wants to merge 1 commit into
mainfrom
fix/keycloak-java4shell
Open

Teg79 wants to merge 1 commit into
mainfrom
fix/keycloak-java4shell

Conversation

@Teg79

@Teg79 Teg79 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Mitigates Java4Shell (CVE-2026-114938, #130) in every JVM Urbex runs, until images with a fixed OpenJDK exist. The mitigation is -XX:-UseBASE64Intrinsics, Keycloak's recommended one: it turns off the OpenJDK Base64 intrinsic that corrupts memory on x86-64 CPUs with AVX-512 VBMI.

  • internal/bootstrap/stacks.go: Keycloak's Stack gets JAVA_OPTS_APPEND=-XX:-UseBASE64Intrinsics in its config.env (JavaMitigationFlags). kc.sh appends it to the JVM's options. urbex bootstrap rewrites config.env, so compose recreates Keycloak on existing platforms too.
  • platform/dockerfiles/java.Dockerfile: the runtime: java image (Temurin 21 JRE) sets JAVA_TOOL_OPTIONS=-XX:-UseBASE64Intrinsics. Services get it with their next build. An app that sets its own JAVA_TOOL_OPTIONS replaces it, as the comment says.
  • Other JVMs: none among the base services (Forgejo, Komodo, Technitium, Grafana, Prometheus, Loki, Alloy, PostgreSQL, cloudflared are Go, Rust, .NET or C).
  • e2e/run.sh: Keycloak's Java process carries the flag (docker top on its LXC).
  • internal/bootstrap/public_test.go: Keycloak's config.env has it.
  • CHANGELOG.md: a ### Security entry under Unreleased, for a patch release if Teg decides on one.

Still to do (issue's second point): bump to a Keycloak image with a fixed OpenJDK, pinned by digest, once one is published; then decide whether to keep the flag.

Companion: urbforge/urbex#101.

Why

#130: pre-login exploitation is reported in Keycloak, and Urbex's realms are public with Cloudflare. A platform on a CPU with AVX-512 VBMI (recent Intel Xeon/Core, AMD Zen 4/5) is exposed.

Tests I ran

  • mise run test, mise run lint: pass.
  • mise run e2e: passed, 24 steps, with the new check that Keycloak's JVM runs with -XX:-UseBASE64Intrinsics, and Keycloak's logins (the projects' realms) working.
  • Locally, in podman:
    • quay.io/keycloak/keycloak:26.7.5 (OpenJDK 21.0.12.1) with JAVA_OPTS_APPEND: the flag is in the JVM's command line, and an admin login works;
    • eclipse-temurin:21-jre with JAVA_TOOL_OPTIONS: UseBASE64Intrinsics = false {environment}.
  • Not run: on the lab. Cubotto's CPU (Xeon E3-1265L v2) has no AVX-512, so neither the bug nor its mitigation shows there; an exploit was not tried.

Checklist before review

  • Linked issue, Conventional Commit title
  • Tests added (unit, e2e)
  • CHANGELOG entry, docs in the companion PR
  • No secrets, tokens or private addresses

Part of #130 (the mitigation; the fixed image follows).

🤖 Generated with Claude Code

https://claude.ai/code/session_0182yxsfwRowwnxCfgrQwjnA

…untime: java without the Base64 intrinsic

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0182yxsfwRowwnxCfgrQwjnA
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants