From 22613f0349148d073203e7f44d234605dedaa33a Mon Sep 17 00:00:00 2001 From: Geoff Bourne <988985+itzg@users.noreply.github.com> Date: Tue, 17 Nov 2026 18:08:00 -0600 Subject: [PATCH] Mitigate Java4Shell by disabling UseBASE64Intrinsics for Java 17 and later versions (#4400) --- docs/configuration/jvm-options.md | 4 ++++ scripts/start-finalExec-jvmFlags | 13 ++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/docs/configuration/jvm-options.md b/docs/configuration/jvm-options.md index 255bafa1..4255d153 100644 --- a/docs/configuration/jvm-options.md +++ b/docs/configuration/jvm-options.md @@ -160,3 +160,7 @@ When `MEMORY` is greater than or equal to 12G, then the Aikar flags will be adju The set of flags documented there can be added by setting the environment variable `USE_MEOWICE_FLAGS` to `true`. There is an optional `USE_MEOWICE_GRAALVM_FLAGS` variable to enable GraalVM specific optimizations, defaults to `FALSE`. MeowIce's flags use the G1 garbage collector by default. MeowIce also provides a [ZGC version of the flags](https://github.com/MeowIce/meowice-flags#zgc-version-for-large-servers-with-32gb-allocated-heap), which is recommended for servers with 32GB or more of allocated memory and many CPU cores. To use it instead, also set `USE_MEOWICE_ZGC_FLAGS` to `true`. When `MAX_MEMORY` (or `MEMORY`) is larger than 2GB, the soft max heap size is set to 2GB below it, as in MeowIce's flags. + +## Mitigating Java4Shell exploit (CVE-2026-114938) + +By default the image will mitigate the Java4Shell exploit (CVE-2026-114938) by disabling `UseBASE64Intrinsics` with `-XX:-UseBASE64Intrinsics` when using Java 17 or later. This can be disabled by setting the environment variable `FIX_JAVA4SHELL_EXPLOIT` to `false`. \ No newline at end of file diff --git a/scripts/start-finalExec-jvmFlags b/scripts/start-finalExec-jvmFlags index 29c566de..c9189361 100755 --- a/scripts/start-finalExec-jvmFlags +++ b/scripts/start-finalExec-jvmFlags @@ -5,9 +5,7 @@ : "${USE_MEOWICE_GRAALVM_FLAGS:=false}" : "${USE_MEOWICE_ZGC_FLAGS:=false}" -if isTrue "${USE_MEOWICE_FLAGS}" || isTrue "${USE_MEOWICE_GRAALVM_FLAGS}"; then - java_major_version=$(mc-image-helper java-release) -fi +java_major_version=$(mc-image-helper java-release) if isTrue "${USE_MEOWICE_FLAGS}"; then if [[ $java_major_version -gt 16 ]]; then @@ -235,3 +233,12 @@ if isTrue "${USE_SIMD_FLAGS}"; then --add-modules=jdk.incubator.vector " fi + +# if java >= 17, mitigate Java4Shell exploit (CVE-2026-114938) by disabling UseBASE64Intrinsics with +# -XX:-UseBASE64Intrinsics +if [[ $java_major_version -ge 17 ]] && isTrue "${FIX_JAVA4SHELL_EXPLOIT:-true}"; then + JVM_XX_OPTS="${JVM_XX_OPTS} + -XX:-UseBASE64Intrinsics + " + log "Disabling UseBASE64Intrinsics to mitigate Java4Shell exploit (CVE-2026-114938)" +fi