I Tried Out the Java4Shell-Related Rules That Were Added to AWS WAF Managed Rules

I Tried Out the Java4Shell-Related Rules That Were Added to AWS WAF Managed Rules

I tested the three Java4Shell rules added to AWS WAF managed rule group AWSManagedRulesKnownBadInputsRuleSet (Version_1.28) on an ALB with fixed responses. A test script confirmed attack code in request headers was detected.
2026.11.18

This page has been translated by machine translation. View original

Introduction

In the AWS Managed Rules changelog dated 2026-11-17, Version_1.28 of the Known bad inputs rule group was released. It adds 3 rules for CVE-2026-114938 (Java4Shell).

https://docs.aws.amazon.com/waf/latest/developerguide/aws-managed-rule-groups-changelog.html

In this article, I associated a Web ACL with the Version_1.28 rule group added to an ALB that returns a fixed response, and verified how the Java4Shell rules behave.

Added rules

The following 3 rules were added in Version_1.28.

Rule Inspection target Default action
Java4Shell_HEADER Request headers Count
Java4Shell_QUERYARGUMENTS Values of all query parameters Count
Java4Shell_BODY Request body Count

Because the default is Count, matches are only recorded in the WAF logs until you change it to Block.

The default version in ap-northeast-1 is currently Version_1.26, so you need to specify Version_1.28 to use the Java4Shell rules. You can check the default version and the latest version with the following command.

$ aws wafv2 list-available-managed-rule-group-versions --scope REGIONAL --vendor-name AWS --name AWSManagedRulesKnownBadInputsRuleSet --region ap-northeast-1 --query '{Default:CurrentDefaultVersion,Latest:Versions[0].Name}'
{
    "Default": "Version_1.26",
    "Latest": "Version_1.28"
}

Test environment

The region is ap-northeast-1. For the test, I prepared the following ALB and WAF configuration.

  • ALB: The HTTP 80 listener returns a fixed response with status code 200 and the body ok. Connections to HTTP 80 are allowed only from the source specified by AllowedCidr.
  • Web ACL: Adds the Known bad inputs rule group with Version_1.28 specified. The whole rule group is overridden to Count with OverrideAction.
  • Logs: The Web ACL logs are output to CloudWatch Logs.

The following waf-alb.yaml creates all of these in a single stack.

aws cloudformation deploy --stack-name j4s-mr-one --template-file waf-alb.yaml --parameter-overrides VpcId=<VPC ID> SubnetIds=<Subnet ID 1>,<Subnet ID 2> AllowedCidr=<Source IP>/32 --no-fail-on-empty-changeset
waf-alb.yaml
AWSTemplateFormatVersion: '2010-09-09'
Description: >-
  Test ALB that returns a fixed 200 on HTTP 80, with a web ACL that has
  AWSManagedRulesKnownBadInputsRuleSet (pinned version) overridden to Count and
  logging to CloudWatch Logs. Delete the stack when done.

Parameters:
  VpcId:
    Type: AWS::EC2::VPC::Id
  SubnetIds:
    Type: List<AWS::EC2::Subnet::Id>
    Description: Two or more public subnets in different Availability Zones.
  AllowedCidr:
    Type: String
    Description: Source CIDR allowed to reach the ALB, for example 203.0.113.10/32.
    AllowedPattern: '^(\d{1,3}\.){3}\d{1,3}/\d{1,2}$'
  RuleGroupVersion:
    Type: String
    Default: Version_1.28

Resources:
  AlbSecurityGroup:
    Type: AWS::EC2::SecurityGroup
    Properties:
      GroupDescription: Java4Shell test ALB, HTTP from one CIDR
      VpcId: !Ref VpcId
      SecurityGroupIngress:
        - IpProtocol: tcp
          FromPort: 80
          ToPort: 80
          CidrIp: !Ref AllowedCidr

  Alb:
    Type: AWS::ElasticLoadBalancingV2::LoadBalancer
    Properties:
      Type: application
      Scheme: internet-facing
      SecurityGroups: [!Ref AlbSecurityGroup]
      Subnets: !Ref SubnetIds

  Listener:
    Type: AWS::ElasticLoadBalancingV2::Listener
    Properties:
      LoadBalancerArn: !Ref Alb
      Port: 80
      Protocol: HTTP
      DefaultActions:
        - Type: fixed-response
          FixedResponseConfig:
            StatusCode: '200'
            ContentType: text/plain
            MessageBody: ok

  LogGroup:
    Type: AWS::Logs::LogGroup
    Properties:
      LogGroupName: aws-waf-logs-j4s-managed-rules
      RetentionInDays: 7

  WebAcl:
    Type: AWS::WAFv2::WebACL
    Properties:
      Scope: REGIONAL
      DefaultAction:
        Allow: {}
      VisibilityConfig:
        SampledRequestsEnabled: true
        CloudWatchMetricsEnabled: true
        MetricName: j4s-managed-rules
      Rules:
        - Name: KnownBadInputs
          Priority: 10
          OverrideAction:
            Count: {}
          Statement:
            ManagedRuleGroupStatement:
              VendorName: AWS
              Name: AWSManagedRulesKnownBadInputsRuleSet
              Version: !Ref RuleGroupVersion
          VisibilityConfig:
            SampledRequestsEnabled: true
            CloudWatchMetricsEnabled: true
            MetricName: j4s-known-bad-inputs

  Association:
    Type: AWS::WAFv2::WebACLAssociation
    DependsOn: Listener
    Properties:
      ResourceArn: !Ref Alb
      WebACLArn: !GetAtt WebAcl.Arn

  Logging:
    Type: AWS::WAFv2::LoggingConfiguration
    Properties:
      ResourceArn: !GetAtt WebAcl.Arn
      LogDestinationConfigs:
        - !GetAtt LogGroup.Arn
      RedactedFields:
        - SingleHeader:
            Name: authorization
        - SingleHeader:
            Name: cookie

Outputs:
  AlbDnsName:
    Value: !GetAtt Alb.DNSName

Overriding to Block

To set the 3 Java4Shell rules to Block, set the rule group's OverrideAction to None and specify the 3 rules as Block in RuleActionOverrides. Replace the KnownBadInputs rule in waf-alb.yaml with the following content, and update the stack with the same command.

        - Name: KnownBadInputs
          Priority: 10
          OverrideAction:
            None: {}
          Statement:
            ManagedRuleGroupStatement:
              VendorName: AWS
              Name: AWSManagedRulesKnownBadInputsRuleSet
              Version: !Ref RuleGroupVersion
              RuleActionOverrides:
                - Name: Java4Shell_HEADER
                  ActionToUse:
                    Block: {}
                - Name: Java4Shell_QUERYARGUMENTS
                  ActionToUse:
                    Block: {}
                - Name: Java4Shell_BODY
                  ActionToUse:
                    Block: {}
          VisibilityConfig:
            SampledRequestsEnabled: true
            CloudWatchMetricsEnabled: true
            MetricName: j4s-known-bad-inputs

After the update, I confirmed with get-web-acl that the override was set, and sent requests about 20 seconds later.

Test requests

The input form of 64 A characters followed by = is the same as in the following article.

https://dev.classmethod.jp/articles/java4shell-corretto-jvm-flag-waf-count/

I send this form, along with strings with different lengths and endings, in headers, cookies, queries, and bodies. The destination is an ALB with a fixed response that has no Java behind it. Each request carries an X-Test-Id header so it can be matched against the WAF logs. The first argument of the script is the DNS name of the ALB (the stack output AlbDnsName), and the second argument is the prefix for X-Test-Id. Specify c (Count) before updating to Block, and b (Block) after updating.

Test script and execution commands
bash mr_tests4.sh <ALB DNS name> c
bash mr_tests4.sh <ALB DNS name> b
#!/usr/bin/env bash
# Usage: bash mr_tests4.sh <alb-dns-name> <prefix>
set -u
HOST="${1:?usage: mr_tests4.sh <alb-dns-name> <prefix>}"
P="${2:?prefix}"
URL="http://${HOST}/"
rep() { printf "$1%.0s" $(seq 1 "$2"); }
A64="$(rep A 64)"; A65="$(rep A 65)"; A100="$(rep A 100)"; A128="$(rep A 128)"

n=0
req() {
  local name="$1"; shift
  n=$((n + 1))
  local id; id="$(printf '%s%02d' "$P" "$n")"
  local out
  out="$(curl -s -m 10 -w '\t%{http_code}' -H "X-Test-Id: ${id}" "$@" | tr '\n' ' ' | head -c 400)"
  printf '%s\t%s\t%s\n' "$id" "$name" "$out"
}

# Matched in Count (HEADER)
req "match: Authorization 64A="         -H "Authorization: Basic ${A64}=" "$URL"
req "match: Authorization 128A="        -H "Authorization: Basic ${A128}=" "$URL"
req "match: X-Token 64A="               -H "X-Token: ${A64}=" "$URL"
req "match: X-Token 65A="               -H "X-Token: ${A65}=" "$URL"
req "match: X-Token 64A=="              -H "X-Token: ${A64}==" "$URL"
# Not matched in Count (same shape in other locations / lengths)
req "nomatch: X-Token 100A="            -H "X-Token: ${A100}=" "$URL"
req "nomatch: Cookie 64A="              -H "Cookie: session=${A64}=" "$URL"
req "nomatch: query 64A="               "${URL}?t=${A64}="
req "nomatch: body text/plain 64A="     -X POST -H 'Content-Type: text/plain' --data "${A64}=" "$URL"
req "nomatch: body json 64A="           -X POST -H 'Content-Type: application/json' --data "{\"t\":\"${A64}=\"}" "$URL"
# Normal requests
req "normal: GET /"                     "$URL"
req "normal: valid basic auth"          -u user:pass "$URL"
req "normal: padded 36 in Authorization" -H "Authorization: Basic $(rep A 34)==" "$URL"
req "normal: 64A no padding in X-Token" -H "X-Token: ${A64}" "$URL"
req "normal: short malformed 20A="      -H "Authorization: Basic $(rep A 20)=" "$URL"
req "normal: JWT-like cookie"           -H "Cookie: jwt=eyJhbGciOiJIUzI1NiJ9.$(rep e 40).$(rep s 43)" "$URL"
req "normal: JSON body"                 -X POST -H 'Content-Type: application/json' --data '{"name":"test"}' "$URL"

Verification results

Responses under Count and Block

I sent the same 17 inputs once each to the Count configuration and the Block configuration. Each cell shows the response code, the action in the WAF log, and the matched rule, in that order.

Input Count configuration Block configuration
Authorization: Basic + 64 A characters + = 200, ALLOW, Java4Shell_HEADER (COUNT) 403, BLOCK, Java4Shell_HEADER
Authorization: Basic + 128 A characters + = 200, ALLOW, Java4Shell_HEADER (COUNT) 403, BLOCK, Java4Shell_HEADER
X-Token: 64 A characters + = 200, ALLOW, Java4Shell_HEADER (COUNT) 403, BLOCK, Java4Shell_HEADER
X-Token: 65 A characters + = 200, ALLOW, Java4Shell_HEADER (COUNT) 403, BLOCK, Java4Shell_HEADER
X-Token: 64 A characters + == 200, ALLOW, Java4Shell_HEADER (COUNT) 403, BLOCK, Java4Shell_HEADER
X-Token: 100 A characters + = 200, ALLOW, no match 200, ALLOW, no match
Cookie: session= + 64 A characters + = 200, ALLOW, no match 200, ALLOW, no match
Query t= + 64 A characters + = 200, ALLOW, no match 200, ALLOW, no match
64 A characters + = in the body (text/plain, JSON) 200, ALLOW, no match 200, ALLOW, no match
7 normal inputs (GET /, valid Basic auth, 36 characters with correct padding, 64 characters without padding, short malformed token, JWT-like cookie, normal JSON) 200, ALLOW, no match 200, ALLOW, no match

WAF log records

I extracted 4 fields from the WAF log of c01 (Authorization: Basic + 64 A characters + =), sent under the Count configuration.

{
  "action": "ALLOW",
  "terminatingRuleId": "Default_Action",
  "ruleGroupList": [
    {
      "ruleGroupId": "AWS#AWSManagedRulesKnownBadInputsRuleSet#Version_1.28",
      "terminatingRule": null,
      "nonTerminatingMatchingRules": [
        {
          "ruleId": "Java4Shell_HEADER",
          "action": "COUNT",
          "ruleMatchDetails": [
            {
              "conditionType": "REGEX",
              "location": "ANY_HEADER",
              "matchedData": null,
              "matchedFieldName": ""
            }
          ]
        }
      ],
      "excludedRules": null,
      "customerConfig": null
    }
  ],
  "labels": [
    {
      "name": "awswaf:managed:aws:known-bad-inputs:Java4Shell_Header"
    }
  ]
}

When evaluating in advance with Count, look at nonTerminatingMatchingRules inside ruleGroupList.

In b01 of the Block configuration, the matched rule was recorded in terminatingRule inside ruleGroupList.

{
  "action": "BLOCK",
  "terminatingRuleId": "KnownBadInputs",
  "ruleGroupList": [
    {
      "ruleGroupId": "AWS#AWSManagedRulesKnownBadInputsRuleSet#Version_1.28",
      "terminatingRule": {
        "ruleId": "Java4Shell_HEADER",
        "action": "BLOCK",
        "overriddenAction": "COUNT",
        "ruleMatchDetails": null
      },
      "nonTerminatingMatchingRules": [],
      "excludedRules": null,
      "customerConfig": null
    }
  ],
  "labels": [
    {
      "name": "awswaf:managed:aws:known-bad-inputs:Java4Shell_Header"
    }
  ]
}

terminatingRuleId contains the Web ACL-side rule name KnownBadInputs, so check inside ruleGroupList to see which rule blocked the request. overriddenAction shows COUNT, which is the rule's default action.

Summary

Three rules for Java4Shell were added to Version_1.28 of AWS WAF's AWSManagedRulesKnownBadInputsRuleSet. The Java4Shell input form placed in a request header matched Java4Shell_HEADER, and returned 403 under Block.

If you want to mitigate workloads that may be affected by Java4Shell with AWS WAF, I recommend adopting the Known bad inputs managed rule group. When adopting it, explicitly specify Version_1.28 or later, and first evaluate the Java4Shell-related rules with Count.

The fundamental countermeasure is updating the JDK, and fixed versions have already been released for Amazon Corretto and others. Use WAF as an aid for understanding attack requests and as a mitigation measure.

In addition, managed rules are likely to continue to be adjusted and added to, so I recommend checking the latest information. You can receive notifications about managed rule group updates by subscribing to the SNS topic described on the following page.

https://docs.aws.amazon.com/waf/latest/developerguide/waf-using-managed-rule-groups-sns-topic.html

https://dev.classmethod.jp/articles/java4shell-corretto-jvm-flag-waf-count/

https://aws.amazon.com/jp/about-aws/whats-new/2026/11/amazon-corretto-nov-2026-updates/

Share this article

AWSのお困り事はクラスメソッドへ