Skip to content

Add the java4shell detector for Java4Shell (CVE-2026-114938) - #9

Open
devGregA wants to merge 36 commits into
mainfrom
devgrega/java4shell
Open

devGregA wants to merge 36 commits into
mainfrom
devgrega/java4shell

Conversation

@devGregA

Copy link
Copy Markdown
Contributor

Adds the java4shell detector for Java4Shell (CVE-2026-114938), the out-of-bounds write in HotSpot's x86-64 AVX-512 VBMI Base64 decode intrinsic (OpenJDK 17.0.6 and later).

What it does

  • fs / image: finds Java runtimes by their VM library (libjvm.so, jvm.dll, libjvm.dylib) and release file, including jlink'd runtimes, runtimes bundled in products, and dpkg/apk/rpm packages. The verdict comes from the library's compiled-in version line and its ELF/PE/Mach-O architecture; the decoder's stub names show the vulnerable code is present. Only x86-64 is affected. A release file alone does not clear a runtime.
  • Mitigations: -XX:-UseBASE64Intrinsics or -XX:UseAVX<=2 in launcher variables, image env, setenv.sh, jvm.options, systemd units, Compose or Kubernetes env are reported as a fact on a finding that stays vulnerable. A container command that turns the decoder back on voids them.
  • scan repo: Dockerfile FROM and package installs, Compose/Kubernetes/Helm image references, setup-java, .tool-versions, .sdkmanrc, .java-version, Gradle and Maven toolchains.
  • fix: moves image tags to the first fixed build of the same variant (checked by pulling the image, including its base OS) and bumps version files. Lines with no published fix are declined with the reason.
  • FACTS.md records sources, the fixed build per line (17.0.21.1+2, 21.0.13.1+2, 25.0.5.1+2, 27.0.1.1+4), vendor status as of 2026-11-17, and what is still unknown. The CVE-to-JDK-8393212 mapping is inferred from the public write-ups; the OpenJDK and Oracle advisories could not be read.
  • Engine: an optional engine.HeadVisitor lets a detector see each file's first bytes (already read) without reading the file; panics in it are contained like Visit.

Verification

  • Unit tests, vet, gofmt; nine new fuzzers (added to CI).
  • Parity: 39/39 with the release binary, including musl, a forged release file, the +1 build boundary and a source tree of install forms.
  • Three rounds of independent review; all findings fixed.
  • Not run on the build host (module proxy blocked): govulncheck and the php2shell sqlite tests. CI covers both.

🤖 Generated with Claude Code

devGregA and others added 30 commits November 17, 2026 22:32
Fix commit and JDK bug per OpenJDK line, the commit that introduced the
AVX-512 VBMI decode path and the first release on each line that has
it, and the fixed or not-yet-fixed release per vendor and distribution
as of 2026-11-17.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… tests next)

Finds Java runtimes by their VM library and judges each by its CPU
architecture, the version compiled into it and the AVX-512 VBMI decode
stubs it carries, with the release file as a second witness. JVM options
that keep the decoder from being generated are reported as mitigated.
Source trees: Java images, version files, setup-java, toolchains,
buildpacks and distribution packages; fix moves image tags and
setup-java versions after verifying them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ns and filesystem scans

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…itigation in FACTS.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
parity/java4shell.py checks 33 cases (vendor images per line, arm64 and
every platform of a multi-arch image, the fixed SapMachine 21.0.13.1, a
jlink image, bundled product runtimes, Alpine, Debian and Ubuntu packages,
mitigations, hostile inputs, a filesystem scan and an offline source tree)
against verdicts from FACTS.md: 33/33 match. A Dockerfile stage's
JAVA_TOOL_OPTIONS mitigation now also covers the packages it installs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A setenv.sh configures the JVM its start script launches (JAVA_HOME or
JRE_HOME, or java on PATH), not only runtimes inside the product
directory, when the container's command runs that script. The parity
runner can rerun named cases and update only their rows, since Docker
Hub's anonymous pull limit can stop a full run part way: 34/34 match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Corretto versions with its build number in the fourth place
  (21.0.13.11) are no longer judged fixed: CorrettoJava reads them, and
  Judge reports any fourth number above 3 as unknown
- a Dockerfile stage's mitigation is decided from the last ENV of each
  variable, so a later _JAVA_OPTIONS or JAVA_TOOL_OPTIONS undoes it
- CATALINA_OPTS and other script variables cover only the JVM the
  script starts (JAVA_HOME, JRE_HOME or PATH)
- systemd: only JVM-read variables count, HotSpot's order applies
  (_JAVA_OPTIONS last), and unit files and drop-ins are merged by
  systemd's precedence before judging
- settings files in general directories (/etc, /usr/local, /opt) and
  product directories of /opt, /app or /usr are refused as scopes
- shell comments in setenv.sh are ignored
- the VM version line is searched only around " JRE (", so large
  printable files cannot make the regex scan from every position
- setup-java early-access versions are not judged; the fixed tag with
  the lowest build is chosen numerically

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ck, Corretto's republished tags

- FACTS.md: the public writeups as relayed by the lead (Calif, Semgrep):
  CVSS 9.2, the trigger, the products shown exploitable, Oracle's
  affected builds including 8u511b33-perf, the ARM caveat for
  -XX:UseAVX=2, indicators; vendor status rechecked 2026-11-18
- a Java 8 VM library that carries the AVX-512 decoder's stubs (Oracle's
  Performance Pack backport) is vulnerable up to 8u511, unknown above
- severity 9.2, advisories led by Calif's; PingFederate, Spinnaker and
  Gerrit recognised as products
- Amazon republished amazoncorretto:21.0.13-* and 17.0.21-* with the
  fixed builds: fix can now move a Corretto pin to the fixed update's
  tag, after reading it; parity keeps the old images pinned by digest
  and expects the new tags fixed (36/36)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…alone

Review findings 1 and 6. HotSpot on musl names its platform
linux-amd64-musl, which the version-line pattern refused, so Alpine
runtimes were judged by their release file. A release file now never
clears a runtime alone, four bytes 'j9vm' no longer make a library
OpenJ9 (the redirector has no decoder stubs and names
OPENJ9_JAVA_OPTIONS), and a release file that names OpenJ9 next to a
HotSpot library that was read makes the verdict unknown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t fixed

Review findings 2, 12 (JDK 28 updates) and 13. The release data now
has the first build of each fixed release with the fix (17.0.21.1+2,
21.0.13.1+2, 25.0.5.1+2, 27.0.1.1+4; checked in the openjdk update
repositories and recorded in FACTS.md): +0 and +1 lack it. Any
pre-release identifier (beta, internal) and adhoc builds count as
pre-release. A version older than the fixed update is vulnerable
whatever its fourth number. Temurin tags carry the OpenJDK build, so
fix never moves to a fixed release's earlier build, and a JDK 28 update
is unknown, not early access.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review finding 3, as the lead decided: JVM options that keep the
decoder from being generated are recorded on the finding (status
mitigated, the option and where it was set) and the finding stays
vulnerable, so it is shown by default and counts in the exit status.
fix also moves mitigated pins. Parity expectations and README follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tion

Review findings 4 and 9. Words of the container command that turn the
intrinsic back on (-XX:+UseBASE64Intrinsics, -XX:UseAVX=3 or higher)
now count wherever the java they start is: a sh -c script, a java this
scan cannot tie to a runtime. A java @argfile makes a mitigation
unprovable. _JAVA_OPTIONS still applies last. In a source tree the
same holds for a Dockerfile stage's ENTRYPOINT and CMD and a Compose
service's or Kubernetes container's command and args.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review finding 5. setenv.sh is read as assignments to the variables a
start script passes to java (CATALINA_OPTS, JAVA_OPTS,
JVM_SUPPORT_RECOMMENDED_ARGS, the JVM's own variables...): the last
assignment wins, $VAR appends, other variables and echo text do not
count, and a file that sets one of them under a condition, loop or
function counts for nothing. setenv.bat is read the same way and only
for Windows runtimes. Cassandra's jvmNN-*.options apply to Java NN
only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review finding 7. Release files, settings files, dpkg file lists (now
kept only for their libjvm.so and release lines), start scripts and
package data have count and total-byte caps. A target that reaches one
records a problem, and its fixed and not-affected verdicts become
unknown with the reason.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review findings 8, 11 and 12. Installs are recognised with flags before
the verb (yum -y install, apk --no-cache add, apk -U add), vendor
packages (temurin-21-jdk, zulu21-jdk, msopenjdk-21, sapmachine-21-jdk,
Corretto) and default-jre are read, and a version range (17.*, ~17)
counts as unpinned instead of as Java 17. An unpinned Corretto or
SapMachine package is unknown (their fix is published, so it depends
on when the image was built), not "the distribution had no fix"; a Java
28 package is not checked rather than "no fix". jenv names
(temurin64-21.0.13), GraalVM's 22.3.r17 and Zulu's own numbers are
handled, a moving setup-java Temurin version is reported, and a FROM
--platform=linux/arm64 stage is skipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the base OS

Review finding 10. The summary of an image move gives the linux/amd64
digest that was checked, and for a republished tag (Corretto's
21.0.13) says to pull again and how to pin the digest. A tag that comes
from a variable used elsewhere in the file is not edited. When the tag's
variant does not name the base OS (-jre), the verifier reads the current
image too and refuses a move to another distribution (the detector now
annotates an image's os-release). The setup-java summary mentions
check-latest for self-hosted runners.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review finding 14. A pulled image that was read only in part and showed
no runtime is reported as not checked instead of dropping the
reference. The verifier's platform lookups go through the guarded
transport (and --public-registries-only) with the timeout, instead of
image.Platforms. A Java runtime download inside a target (a JDK
tar.gz or zip) is recorded as not scanned. fix summaries say the digest
checked is the tag's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…y claims

Review finding 15. Outside FACTS.md, the mapping of CVE-2026-114938 to
JDK-8393212 is worded as inferred (reasons name it through BugRef), a
fixed runtime is "at or past the first release with the fix (judged by
its version)", the CPU list no longer claims every Intel CPU from Ice
Lake on, and README claims about the release file, finding runtimes
and mitigations match what the detector does. The catalog lists only
advisories that could be read; the OpenJDK and Oracle advisories are
recorded in FACTS.md as unread.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… code

Review finding 16. Tests for tagLister, the verifier and pulled images
against an in-memory registry; fuzzers for ParseRelease, APKOwners,
DpkgOwners, readCrash and assess.Run (which checks that no fuzzed
release file, environment, command or settings file clears an unfixed
library that carries the decoder), added to CI. FuzzReadCrash found
crash-log fields bounded in characters, not bytes: they are now clipped
to bytes (its corpus entry is kept). Release.Arch, Setting.Mentions,
Options.Set and Finding.Optional were unused and are removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ld boundary cases

Review finding 16. Parity rows now include version_from, so a verdict
taken from the release file instead of the VM library fails. New cases:
Temurin 21.0.13 on Alpine (musl), a musl library under a forged release
file, and a synthetic build-boundary case (SapMachine 21.0.13.1+2
rewritten to +1). 39/39 match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Round-2 finding 1. A release file's JVM_VARIANT=Openj9 no longer decides
OpenJ9 on its own: only an OpenJ9 library (libj9vm*, or the redirector
without a HotSpot version line or decoder stubs) does, and any
HotSpot version line or decoder stubs next to OpenJ9 evidence give
unknown. A HotSpot library with the decoder whose version line is not
parsed, under a release file naming OpenJ9, was not affected; it is now
unknown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…not pre-release

Round-2 finding 3. A self-built JDK (-internal, adhoc) has no release
build number, so at the update the decoder came with (17.0.6) or the
release the fix landed in (17.0.21.1...) it is unknown instead of
judged by its build; a self-build of an older update is still
vulnerable. A -LTS suffix or an rpm release (21.0.13.1.2-1.el9) after
the version is no longer read as a pre-release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Round-2 finding 2. Keywords count only in command position (so "echo
done" no longer closes a block); function bodies and "&& { }" groups
are conditional; heredoc text is skipped; commands on one line are read
in order and unset clears a variable; the JVM's own variables count
only when exported; only the launcher's variables count (catalina.sh:
JAVA_OPTS, CATALINA_OPTS; JVM_SUPPORT_RECOMMENDED_ARGS only for
Atlassian products), applied in the order the JVM sees them
(JAVA_TOOL_OPTIONS, JDK_JAVA_OPTIONS, JAVA_OPTS, CATALINA_OPTS,
_JAVA_OPTIONS). Multi-line values, helper variables and sourced files
are still not modelled; they are not counted, which leaves the runtime
vulnerable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…unt toward the cap

Round-2 findings 4 and 5.

The engine gets an optional HeadVisitor: a scan that implements it sees
the first bytes of every file the walk meets, read or not. java4shell
uses it to record Java runtime downloads (names anchored to how vendors
publish them: OpenJDK21U-jre_..., amazon-corretto-21-..., zulu21...-ca-
jdk21..., jdk-21_linux-x64_bin...) as the annotation
java4shell_runtime_archives, without reading them and without counting
them as files not scanned. Other archives are not recorded.

Only settings files that set a JVM option count toward the settings
cap; systemd units without one are kept as small records under their
own cap, since an /etc override without options still replaces the
unit it overrides. dpkg lists are filtered without splitting them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Round-2 finding 6. A RUN line is split into commands, and only the
arguments of an install command (<tool> [flags] install|add) are
matched, whole, against the Java package patterns: flags and their
values, paths and URLs are not packages. A Temurin tarball moved to
/opt/temurin-17 or a Zulu download URL on the same line is no longer
reported as an installed package.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…and major version

Round-2 finding 7. The verifier now compares the current and the new
image's os-release for every move, also when the variant names the
distribution (an -alpine or -noble tag can move to the next release),
on ID and major version, so a minor update (Oracle Linux 9.5 to 9.6,
Alpine 3.21 to 3.22) is accepted and Ubuntu 24.04 to 26.04 is not. The
current image is read with a probe that reads only os-release, not a
second full scan. A current tag that is gone is tolerated when the new
tag names its OS. os-release values are cut to 32 plain characters and
decline reasons go through the usual clean-up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Round-2 nits. Every date in the detector's text comes from the
knowledge package: the data date (Checked, now in an AsOf() phrase for
"had not published" statements) and the facts it rests on (Disclosed,
FixReleased, MainlineFixed, VendorFixPublished); a test keeps date
literals out of the other files. The vendor-build reason no longer
reads "whether JDK-8393212, inferred to be this CVE's fix is in". The
README states what a contradicting release file does (only OpenJ9
evidence makes it unknown; a version mismatch is noted), how runtime
downloads are recorded, and that self-built JDKs at a build boundary
are unknown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Round-3 finding 1 (a regression from the round-2 argument parser). The
package tool is looked for only outside flags, so RUN --mount=...,
target=/var/cache/apt no longer hides it; a trailing rpm .arch, Debian
:arch or /target-release is stripped before matching; and a pin to a
variable (=${JDK_PKG}) is reported as a pin of unknown version. Parity's
source-tree case gets the same forms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Round-3 finding 2. A head visitor that panics on one file loses that
file, recorded as not scanned with the detector named, and the scan of
the target goes on for every detector. Tests cover that and the branch
where another detector wants every file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
devGregA and others added 6 commits November 18, 2026 02:24
Round-3 finding 3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ndoes it voids it

Round-3 nit. Assignments after an unconditional return or exit are not
read. A java the file starts itself with -XX:+UseBASE64Intrinsics,
-XX:UseAVX=3 or higher, or an @argfile, makes the file's mitigation
unprovable (a java named by path, $JAVA_HOME/bin/java, counts as java).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Round-3 nit. SameBase compares Ubuntu on its full VERSION_ID and other
distributions on the major version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…release

Round-4 follow-ups. An apk argument with a repository tag
(openjdk21-jre-headless@edge) is matched like one with an .arch or
:arch suffix. A Java package name with a variable where the release is
(openjdk-${V}-jre-headless, java-${V}-openjdk) is reported as not
checked, like a pin to a variable version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant