
Trying Out Amazon Corretto Updates, JVM Flags, and AWS WAF Count Rules as Countermeasures for Java4Shell (CVE-2026-114938)
This page has been translated by machine translation. View original
Introduction
On 2026-11-17, OpenJDK issued an advisory for Java4Shell (CVE-2026-114938), a vulnerability in the Base64 decoder.
AWS has also published the status of its Amazon Linux package fixes.
Java4Shell is a vulnerability that causes an out-of-bounds heap write in Base64 decoding that uses the x86-64 AVX-512 VBMI instructions. In this article, I checked the fixed versions of Amazon Corretto, how to set and apply JVM flags in Docker, and an AWS WAF Count rule attached to an ALB.
Overview of Java4Shell
Conditions for impact
CISA warns that a crafted Base64 input can crash the JVM and could lead to unauthenticated remote code execution. Calif also demonstrated an exploit that attacks a Java program simply by having it connect to an external TLS server. For this reason, programs that do not expose a service can also be affected.
Affected environments are those that meet all of the following conditions.
- OpenJDK 17.0.6 or later before the fix, and builds derived from it. Calif lists Amazon Corretto, Eclipse Temurin, Microsoft Build of OpenJDK, Azul Zulu, and others.
- An x86-64 CPU with AVX-512 VBMI. This includes Intel Xeon Ice Lake, Sapphire Rapids, Emerald Rapids, and Granite Rapids, and AMD Zen 4 and later. ARM64 is not affected.
According to Upwind, standard Java 8 and 11 are not affected.
You can check whether the CPU of a Linux host meets the conditions with the following command shown by Calif. If all four flags are output, the host is affected.
grep -m1 '^flags' /proc/cpuinfo | tr ' ' '\n' | grep -E '^(avx512f|avx512bw|avx512vbmi|bmi2)$'
For containers, even with the same image, whether you are affected depends on the CPU of the node it runs on.
Order of priority for response
Since fixed versions of Corretto have been released, updating to the fixed version is the top priority. If you cannot update right away, set the JVM flag -XX:-UseBASE64Intrinsics as a mitigation until you can update.
Updating to the fixed Corretto versions
Guidance on the Corretto releases that fix Java4Shell (CVE-2026-114938) is provided on the following page.
Fixed versions and where to get them
The CHANGELOG of the latest release of each line (2026-11-17) lists the fix for CVE-2026-114938 (CVSS 8.1).
| Line | Fixed version | Source |
|---|---|---|
| 17 | 17.0.21.1.2 | corretto-17 CHANGELOG |
| 21 | 21.0.13.1.2 | corretto-21 CHANGELOG |
| 25 | 25.0.5.1.2 | corretto-25 CHANGELOG |
| 27 | 27.0.1.1.4 | corretto-27 CHANGELOG |
The tar.gz download URL has the following form, containing the version and the CPU architecture (x64 or aarch64). For the four versions in the table above, I confirmed that all 8 URLs (x64 and aarch64) return HTTP 200.
https://corretto.aws/downloads/resources/<版>/amazon-corretto-<版>-linux-<x64|aarch64>.tar.gz
There are also URLs that point to the latest version. The following URL for 17 redirects with HTTP 302 to the 17.0.21.1.2 tar.gz.
https://corretto.aws/downloads/latest/amazon-corretto-17-x64-linux-jdk.tar.gz
Docker images
On Docker Hub's amazoncorretto, the images that the major version tags (17, 21, 25, 27) point to were the fixed versions. The same was true for the version tags (17.0.21, 21.0.13, 25.0.5, 27.0.1). I checked using arm64 images.
$ docker run --rm amazoncorretto:17 java -version
openjdk version "17.0.21.1" 2026-11-17 LTS
OpenJDK Runtime Environment Corretto-17.0.21.1.2 (build 17.0.21.1+2-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.21.1.2 (build 17.0.21.1+2-LTS, mixed mode, sharing)
You can confirm whether it is a fixed version from the Corretto version shown by java -version.
Setting JVM flags
Upwind's test environment was Temurin 17.0.6, 17.0.21, 21.0.13, and 25.0.5 on AWS c6i (Intel Ice Lake). They state that -XX:-UseBASE64Intrinsics stopped the out-of-bounds write in this environment. This flag disables the optimization that uses AVX-512 VBMI instructions for Base64 decoding, so the problematic code is not executed.
Setting it in a Dockerfile
Here, I checked the setting and application of the JVM flag in an ARM environment that is not affected by the vulnerability. If you set JAVA_TOOL_OPTIONS with the ENV instruction in a Dockerfile, the flag is passed to JVMs started from that image.
FROM amazoncorretto:17
ENV JAVA_TOOL_OPTIONS="-XX:-UseBASE64Intrinsics"
In the directory containing the Dockerfile, I built it with the image name j4s-flag-check:env.
docker build -t j4s-flag-check:env .
Confirming it is applied
Use PrintFlagsFinal to check the value of UseBASE64Intrinsics and where it was set.
# No flag specified (default)
$ docker run --rm amazoncorretto:17 java -XX:+PrintFlagsFinal -version 2>&1 | grep -E "UseBASE64Intrinsics|UseAVX |openjdk version"
bool UseBASE64Intrinsics = true {product} {default}
openjdk version "17.0.21.1" 2026-11-17 LTS
# Specify the flag on the command line
$ docker run --rm amazoncorretto:17 java -XX:-UseBASE64Intrinsics -XX:+PrintFlagsFinal -version 2>&1 | grep -E "UseBASE64Intrinsics|UseAVX |openjdk version"
bool UseBASE64Intrinsics = false {product} {command line}
openjdk version "17.0.21.1" 2026-11-17 LTS
# Image with JAVA_TOOL_OPTIONS added via ENV in the Dockerfile
$ docker run --rm j4s-flag-check:env java -XX:+PrintFlagsFinal -version 2>&1 | grep -E "Picked up|UseBASE64Intrinsics|UseAVX |openjdk version"
Picked up JAVA_TOOL_OPTIONS: -XX:-UseBASE64Intrinsics
bool UseBASE64Intrinsics = false {product} {environment}
openjdk version "17.0.21.1" 2026-11-17 LTS
For a running container, you can check with jcmd (the amazoncorretto:17 image includes jcmd). The following is the result of running it in a Java container (named j4s-wait) started with JAVA_TOOL_OPTIONS passed via docker run -e.
$ docker exec j4s-wait jcmd 1 VM.flags -all | grep UseBASE64Intrinsics
Picked up JAVA_TOOL_OPTIONS: -XX:-UseBASE64Intrinsics
bool UseBASE64Intrinsics = false {product} {environment}
$ docker exec j4s-wait jcmd 1 VM.command_line
Picked up JAVA_TOOL_OPTIONS: -XX:-UseBASE64Intrinsics
1:
VM Arguments:
jvm_args: -XX:-UseBASE64Intrinsics --add-modules=ALL-DEFAULT
java_command: jdk.compiler/com.sun.tools.javac.launcher.Main Wait.java
java_class_path (initial): .
Launcher Type: SUN_STANDARD
Other flags
Calif lists -XX:UseAVX=2 as another mitigation. This flag disables AVX-512, and should be set only on x86-64 hosts. An ARM JVM does not recognize this flag, so in environments that mix ARM and x86-64, use -XX:-UseBASE64Intrinsics.
If you use -XX:DisableIntrinsic=_base64_decodeBlock, place -XX:+UnlockDiagnosticVMOptions before it. This is because it is a diagnostic option.
AWS WAF Count rule
AWS WAF may be able to detect Java4Shell attack requests. In environments where you cannot update or set the flag right away, consider evaluating with Count and then changing to Block.
I used a CloudFormation template that counts requests containing a malformed Base64 token. I attached a Web ACL to an ALB (HTTP 80, fixed response 200) and checked it in ap-northeast-1 with RuleAction=Count.
Contents of the rules
The Web ACL has four rules, and the default action is Allow. All four reference the same regular expression pattern set.
| Priority | Rule | Inspection target |
|---|---|---|
| 10 | MalformedBase64-AuthorizationHeader | Authorization header |
| 20 | MalformedBase64-CookieValues | Values of all cookies |
| 30 | MalformedBase64-QueryString | Query string (as is and after URL decoding) |
| 40 | MalformedBase64-Body | Body (first 8 KB on an ALB) |
A match occurs when a value contains a token that satisfies the following conditions.
- It starts at the beginning of the value, or immediately after a character other than
A-Za-z0-9+/_-. - It has a run of 32 or more characters from
A-Za-z0-9+/_-. 32 characters is the length Upwind gives as a guideline for detection, while the condition for the attack to succeed shown by Calif is 64 or more characters (128 or more on OpenJDK 17). - It ends with
=, and that sequence is not valid padding. Valid padding is blocks of 4 characters followed by either 2 characters and==, or 3 characters and=.
For example, a value of 64 A characters followed by = matches. A value that is correctly padded, such as one ending in AA==, or a value without padding (each part of a JWT) does not match.
Deployment
The template is in the following GitHub repository.
Specify the ARN of the target ALB in AssociateResourceArn. If you specify EnableLogging=true, the Web ACL logs are output to CloudWatch Logs, and you can use them to check Count results.
aws cloudformation deploy \
--stack-name waf-java4shell-base64 \
--template-file template.yaml \
--region ap-northeast-1 \
--parameter-overrides \
Scope=REGIONAL \
RuleAction=Count \
EnableLogging=true \
AssociateResourceArn=arn:aws:elasticloadbalancing:REGION:ACCOUNT_ID:loadbalancer/app/NAME/ID
Only one Web ACL can be attached to a resource. If you specify an ALB that already has a Web ACL attached in AssociateResourceArn, the existing Web ACL is replaced by the template's Web ACL. In that case, do not attach the template's Web ACL; instead, port the rules to the existing Web ACL.
Confirming Count
I sent test requests to a fixed-response ALB prepared for testing.
BAD="$(printf 'A%.0s' {1..64})="
curl -H "Authorization: Basic ${BAD}" http://<alb-dns-name>/
curl "http://<alb-dns-name>/?t=${BAD}"
curl -u user:pass http://<alb-dns-name>/
The names of the rules that counted were recorded in nonTerminatingMatchingRules in the WAF logs. The values of Authorization and Cookie are shown as REDACTED, but rule matches are recorded.
The following are the results for each request, as confirmed in the WAF logs.
| Request | Rule that counted |
|---|---|
Authorization: Basic + A×64 + = |
MalformedBase64-AuthorizationHeader |
Query ?t= + A×64 + = |
MalformedBase64-QueryString |
| Valid Basic authentication (user:pass) | None |
Summary
Java4Shell is a vulnerability in the Base64 decoding of OpenJDK running on x86-64 CPUs with AVX-512 VBMI.
If you use Corretto, I recommend updating to the fixed version. If you run on an x86-64 CPU with AVX-512 VBMI and cannot update Corretto right away, use the following mitigation: set the JVM flag -XX:-UseBASE64Intrinsics through JAVA_TOOL_OPTIONS.
AWS WAF has a limited scope of protection, but it may be able to detect malformed Base64 tokens. After checking for side effects with Count, please use it as a mitigation combined with rate rules and the like.
