Your build targets Java 21. Which JDK actually ran?

17 minute read     Updated:

Brandon Schurman
Brandon Schurman

On November 17, Calif disclosed Java4Shell (CVE-2026-114938), a memory-corruption vulnerability in OpenJDK’s Base64 decoder. Oracle released Java updates the same day. For platform teams, the immediate question is which services actually run an affected Java Development Kit (JDK).

Searching build files for “Java 21” will turn up patched projects and projects still needing an update. A compilation target does not tell you the JDK’s patch level, and the runtime serving production traffic may differ from the one that built the application.

To work out what needs changing, keep three things separate: the declared target, the JDKs that ran in continuous integration (CI), and the runtime serving production traffic. A search through build files answers only part of the first question.

TL;DR

  • Track declared Java targets, observed CI JDKs, and production runtimes separately.
  • Compare each JDK major with its own vendor-approved patch floor.
  • Verify deployed workloads after rollout, then retain checks to catch regressions.

Follow one service through the patch

Consider a hypothetical service called checkout-api. Its Maven configuration contains:

<maven.compiler.release>21</maven.compiler.release>

Suppose checkout-api uses Oracle JDK 21.0.13 in CI, and a separate inspection finds the same version in its production container. Both need updating.

The Maven setting can stay at 21 while the team upgrades CI to 21.0.13.1. Change whatever selects the CI JDK, such as the runner setup or build image. Then rerun the relevant jobs and check the versions they actually used.

The production container has its own runtime and needs a separate update and rollout. Updating the CI runner leaves the JDK inside an already running container unchanged.

The vulnerable code path requires an x86-64 processor with AVX-512 VBMI support. Assess the relevant build and execution environment against the research disclosure; a Java major version alone cannot establish exposure.

Use the applicable vendor’s advisory to decide which builds need replacing. Oracle’s November security advisory covers the vulnerability; the example here uses Oracle versions. Other distributions need their own fixed-version requirements.

“Newer than Java 21” is the wrong comparison

A minimum of 21.0.13.1 sounds reasonable until a service builds with a Java 25 JDK that still needs the fix. Numerically, 25 clears that floor. It still needs the fix for its own release line.

Set a separate minimum for each JDK line in scope. For Oracle JDK 17, 21, 25, and 27, this example uses 17.0.21.1, 21.0.13.1, 25.0.5.1, and 27.0.1.1. The table shows the expected decisions under these floors.

CI evidence Decision Reason
21.0.13 Fail Below the Java 21 floor of 21.0.13.1.
21.0.13.1 Pass Meets the Java 21 floor; says nothing about production.
25.0.5 Fail Below the Java 25 floor of 25.0.5.1, despite being newer than Java 21.

Every observed JDK needs to meet its own floor. If one job uses 21.0.13.1 and another uses 21.0.13, the latter still needs updating. A successful observation from the first job cannot cover the second.

Keep the source of each observation: the service, commit, CI job, command or executable, and when it ran. Otherwise, an old successful build can look like evidence for the current change. If the compiler or tests use a different JDK from the build tool, capture those versions too.

Close the production gap

For checkout-api, the remaining question is which runtime is actually serving requests. Start by identifying the Java executable used by the application process. Running java -version in a shell only checks whichever executable that shell selects, which may be different.

If jcmd is available and can attach to the application process, jcmd <pid> VM.version reports the running Java virtual machine (JVM)’s version. Run it on the same machine with the same effective user and group as the target JVM. In a container, it also needs access to that process. Otherwise, use runtime inventory or startup records tied to the specific application process.

Record the vendor and full version alongside the workload identity and deployed artifact. For a container rollout, identify the image by digest rather than relying on a tag such as java21. Tags can point to different images over time; digests identify fixed image content.

Check the configuration that selects the production runtime, including Dockerfile base images or virtual machine (VM) image references, against approved patched builds. Update those references so a later rebuild or replacement does not bring back the outdated JDK.

Rebuild the application image with the patched runtime and verify its JDK before deploying it. Then check the workloads receiving traffic. During a rolling update, old and new replicas may coexist, so one patched instance does not establish that the whole service is updated. On hosts, restart affected Java processes after replacing the JDK, then check what they run.

For checkout-api, the patch campaign is complete when fresh CI observations meet the configured floors and the production inventory confirms the approved runtime across the instances in scope. Until then, report “CI updated; production unverified.”

Keep the inventory current across repositories

Small teams may be able to check their entire fleet manually or rely on a universally deployed shared template. But for large teams with many repositories and diverse tech stacks, knowing which services are affected can be a time-consuming process.

Earthly Lunar collects repository declarations and observed java or javac commands into a shared data model, then evaluates centrally managed policies. Those policies can enforce a minimum major version declared statically in Maven or Gradle, and the CI collector queries the exact traced executable for its version. Lunar installs centrally, and collects software development lifecycle (SDLC) metadata across all of your repositories. A CI/CD Tracer (for continuous integration and delivery) is installed alongside your runners to collect data from pipelines without modifying any workflows.

This lunar-config.yml example ensures a minimum JDK build target and that the version of the Java command-line tools used in CI includes the patch. It assumes Oracle JDK 17, 21, 25, or 27.

collectors:
  - uses: github://earthly/lunar-lib/collectors/java@v1.26.0
    on: ["domain:engineering"]
    include: [project, cicd]

policies:
  - uses: github://earthly/lunar-lib/policies/java@v1.26.0
    name: java4shell
    on: ["domain:engineering"]
    enforcement: block-pr-and-release
    include: [min-java-version, min-java-version-cicd]
    failureText: |
      Update the JDK to meet the configured
      Oracle patch requirement for CVE-2026-114938.
      {{ .check.failure }}
    with:
      min_java_version: "17, 21, 25, 27"
      min_java_version_cicd: "17.0.21.1, 21.0.13.1, 25.0.5.1, 27.0.1.1"
      require_java_version_cicd: "true"

min-java-version checks each declared build target against the four release lines: a normal 21 passes, and a target on an unlisted or older release fails, such as end-of-life Java 23, which won’t get this fix.

min-java-version-cicd holds every JDK that CI ran to the floor for its own release. As the Java policy documentation explains, older releases fail, unlisted releases between the listed floors fail, and releases newer than every listed floor pass. It reads the version each JDK reports, not who built it, so any vendor’s 21.0.13.1 passes. Where a distribution numbers its fix differently, give the components that use it their own policy entry with that vendor’s floors. With require_java_version_cicd: "true", it also fails a Java project whose CI recorded no Java version.

block-pr-and-release prevents teams from merging pull requests or releasing new versions of their service until they meet this critical patch requirement. Alternatively, you can introduce the check at the score level first to monitor its performance and see which services are affected before enforcing action on developers.

Next steps: extend coverage

Other Lunar guardrails cover more of the same vulnerability. Lunar can run Grype across every repository and published image centrally, or use the container-scan and sca guardrails to require that a scanner such as Snyk has run. With the Docker collector, min-java-version-base-image also holds the off-the-shelf Java base images that Dockerfiles typically build on, such as eclipse-temurin and amazoncorretto, to a patch floor. This check has been shown to flag container dependencies that some popular scanners have missed.

The next time someone asks whether checkout-api is patched, the answer should name the CI jobs and production workloads checked and the versions found.

“It targets Java 21” can stay in the build file.

Turn engineering standards into automated checks during AI-assisted authoring, on pull requests, and at deploy gates. Earthly Lunar includes 300+ pre-built guardrails and works with your existing repositories and CI/CD systems.

Brandon Schurman
Brandon is a founding member of the Earthly team and a Platform Engineer at heart. When he’s not at home hacking on the latest Earthly tech, you’ll probably find him off the grid, relaxing at a campsite with his family.

Published:

Get notified about new articles!
We won't send you spam. Unsubscribe at any time.