Java4Shell: Buy Time with a WAF, Then Update the JDK

Executive Summary
On November 17, 2026, the OpenJDK project and Oracle disclosed CVE-2026-114938, now known as Java4Shell. It sits in the Base64 decoder that ships with every Java runtime, and on modern Intel and AMD servers, it lets an unauthenticated attacker corrupt the memory of a running Java service with a single crafted string. Calif published a technical write-up that demonstrates remote code execution, and Red Hat rates it 9.8 out of 10. JDK 17, 21, 25, and 27 are affected, which covers the 3 newest long-term-support releases. GreyNoise had already recorded Java4Shell-shaped requests on the internet a day after disclosure, with no confirmed intrusion so far.
The fix is a patched JDK, and Oracle shipped one on November 17. Until it is installed, the vendors recommend a JVM startup flag that disables the vulnerable code. Both mean finding every Java service you run, changing how it starts, and restarting it. An organization with hundreds of Java applications, many of them packaged by vendors, will spend weeks on that.
Our recommendation is to close that window today with a virtual patch at the gateway, then update the JDK on your own schedule. We wrote a rule for the WAF built into Traefik Hub and tested it against a real Java 17 service on a server CPU that has the vulnerable instructions. It blocked every published trigger shape we sent in form fields, JSON, headers, cookies, and login credentials, and it let ordinary Base64 traffic through: 0 false positives across 160 random samples. On a real Java service, it costs less than 1% of throughput for typical requests.
The rest of this post explains the flaw in plain terms, shows what we tested and what it costs, and gives your platform team the exact configuration. The virtual patch is a stopgap: the flaw stays in every unpatched JVM, so put a date on the JDK update in the same meeting where you approve the rule.
In this post:
- What Java4Shell is, in plain terms
- Why updating the JDK takes longer than attackers need
- One rule at the gateway for every Java service
- What we tested, and what it blocked
- What it costs: the performance trade-off
- For the platform team: the configuration to apply
- A stopgap, not the remediation
- What to do in the next hour
What Java4Shell Is, in Plain Terms
Java has decoded Base64 text the same way for years, through java.util.Base64. Base64 is everywhere in web traffic: HTTP Basic Auth credentials, tokens, file uploads sent inside JSON, signed documents. On recent Intel and AMD server CPUs, the Java runtime quietly swaps that decoder for a faster version that uses the CPU's AVX-512 VBMI instructions. It does this on its own once a service has decoded enough data for the JIT compiler to optimize the hot path, so nobody turns it on, and few teams know it is there.
The faster decoder has a counting bug. When it receives a long Base64 string that ends in malformed padding (a stray =, for example), it miscounts how much output to write and writes 62 bytes past the end of its buffer. Java then notices the input is invalid and throws an error, but the write has already happened. This out-of-bounds write is the starting point for the remote code execution in Calif's write-up.
The trigger is short and specific: a run of at least 64 Base64 characters (128 on older JDK 17 builds), followed by one of 6 malformed endings such as =, ==, or AB=. Any field that a Java service hands to the decoder can carry it, including headers, cookies, form fields, JSON values, and the Basic credentials in an Authorization header.
Exposure depends on 3 things at once, which is why inventories take time:
- The JDK version. OpenJDK 17.0.6 and later, 21, 25, and 27 are affected, according to the OpenJDK advisory of November 17, 2026 and Oracle's November update. Java 11 is not. Oracle shipped fixed builds on November 17 (17.0.21.1, 21.0.13.1, 25.0.5.1, and 27.0.1.1), and the other distributions are following. Aikido's advisory lists the fixed builds and how to check your exposure.
- The CPU. Only x86-64 processors with AVX-512 VBMI take the fast path: Intel Ice Lake and later Xeon generations (Sapphire, Emerald, and Granite Rapids) and AMD Zen 4 and later. ARM servers and older x86 CPUs are not affected. In the cloud, some instance families run on more than one processor generation, so the answer can change when a VM restarts on different hardware.
- The code path. The service must decode attacker-supplied Base64, which many web services do, often inside a framework or library rather than in your own code.
There is also a configuration workaround, and unlike many, it is real. Starting the JVM with -XX:-UseBASE64Intrinsics switches off the fast decoder, and vendors recommend it until a patched JDK is installed. Red Hat also lists -XX:UseAVX=2 as a fallback on x86 hosts only, but that flag turns off all AVX-512 instructions, not just the Base64 decoder. Either flag still means touching the startup flags of every affected Java service and restarting it, which brings us back to the calendar.
Why Updating the JDK Takes Longer Than Attackers Need
Everyone agrees on the fix, and the problem is where Java lives. A JDK is rarely installed once per server. It is baked into container images, bundled inside vendor products and appliances, pinned in build pipelines, and copied into every microservice that was ever started from the same template. Updating it means rebuilding and redeploying each image, waiting for each vendor to ship its own update, and retesting the applications that are certified against one exact Java build. On November 18, a day after disclosure, some distributions had published fixed builds and others had only announced them.
The startup flag is faster, but it has the same reach problem. Someone has to find every JVM, add -XX:-UseBASE64Intrinsics to its startup options (an environment variable, a Helm value, a vendor's own config file), and restart it. Restarting a stateful Java service is a change window, and a vendor appliance does not always expose its JVM options at all.
Exposure is also hard to reason about. Because the CPU is part of the answer, a cloud service safe on Monday can take the vulnerable code path on Tuesday after it restarts on newer hardware.
In a well-run organization, that work takes days. In most organizations, it takes weeks. Each of those days, an attacker who finds one Java service that decodes Base64 from a request (many do, often inside a framework or library) has a path to code execution without credentials.
One Rule at the Gateway for Every Java Service
This is where a virtual patch pays for itself. The Java4Shell trigger has a shape that ordinary traffic does not have: a long run of Base64 that ends in padding no valid encoder produces. A web application firewall (WAF) in front of your services reads each request before any of them does and refuses the ones with that shape. The JVM never receives the string, so the out-of-bounds write the exploit depends on never starts. The WAF does not need to understand the exploit, only its outline, and Calif's write-up documents that outline precisely.
The argument gets stronger with scale. Patching is per JVM; the gateway is shared. If your organization runs hundreds of Java applications, many of them behind the same gateway, one configuration object covers all of them at once, including the vendor products whose JVM options you cannot reach and the services nobody has inventoried yet. It takes effect within seconds, and nothing in the applications changes.

The WAF in Traefik Hub is OWASP Coraza, the open-source engine compatible with ModSecurity's rule language, compiled into the gateway binary rather than run as a separate network hop. Rules use the same SecLang syntax security teams have used for 2 decades, so teams can write and test a rule the same day an advisory lands. Traffic that passes the rules continues to the router unchanged, and traffic the rules catch is refused at the gateway.
What We Tested, and What It Blocked
We did not want to publish a rule checked only against an advisory on paper, so we ran it. The environment was an isolated cloud virtual machine (4 vCPUs) with a processor that supports AVX-512 VBMI instructions, running a Kubernetes cluster, Traefik Hub 3.21.5 with its native WAF middleware, and a Java service on an affected JDK 17 build that passes request fields to Base64.getDecoder().decode(). Every request was built from the inert trigger shape the researchers published (a run of the letter A followed by bad padding), so no exploit was written or run.
The same service sat behind 2 routes, one without protection and one with the virtual patch. Each request went to both. The first 9 requests carry the trigger and must be refused. The last 5 are legitimate Base64 traffic and must pass, so for them, reaching the service is the correct result.
| Request | Without WAF | With the virtual patch |
|---|---|---|
64 × A + = in a form field |
Reached the decoder | 403 |
128 × A + AB= in a form field |
Reached the decoder | 403 |
72 × A + = (length not a multiple of 64) |
Reached the decoder | 403 |
| JSON body, with the padding sent as a JSON Unicode escape | Reached the decoder | 403 |
| Trigger in a custom header | Reached the decoder | 403 |
| Trigger in a cookie | Reached the service | 403 |
| Trigger as HTTP Basic credentials | Reached the service | 403 |
| Trigger as a Bearer token | Reached the decoder | 403 |
| Trigger in a chunked body | Reached the decoder | 403 |
| Random 97-byte Base64 value in a form field | Reached the service | Passed, as expected |
| A JSON Web Token (JWT) | Reached the service | Passed, as expected |
| Valid HTTP Basic credentials | Reached the service | Passed, as expected |
| Valid Base64 with correct padding (68 characters) | Reached the service | Passed, as expected |
| 100 random Base64 values in form fields | All reached the service | All passed, 0 blocked, as expected |
"Reached the decoder" means Java's own decoder rejected the string as invalid. On a vulnerable JVM, that rejection comes after the out-of-bounds write.
The last 5 rows matter as much as the first 9. A virtual patch that breaks logins or tokens gets switched off within the hour, and Base64 shows up in many legitimate requests. Across this run and our full test suite, 160 random Base64 values went through with 0 false positives.
Testing live changed the rule twice. The first version, drafted from the advisory, matched only trigger runs whose length was a multiple of 64. The researchers' write-up says 64 is a minimum, and a 72-character run triggers the bug, so we widened the rule. Our next version passed every check on the bench, then blocked ordinary Base64 values on the live gateway: in a URL-encoded form body, an unescaped + decodes to a space, so a client that sends Base64 without escaping it splits a valid value into pieces that look like bad padding. Anchoring the rule to a whole line of the field value fixed it. Neither problem showed up until real requests went through the real product.
We also want to be precise about one limit. Our test JVM did not show the memory corruption itself: a detector we ran on it, 40 million trigger decodes with canary buffers, found nothing. So what we proved is the gateway's behavior, that the published trigger never reaches the JVM and valid traffic does. Showing that the WAF stops a working exploit would have required running one, and we chose not to.
What It Costs: The Performance Trade-Off
The WAF is not free. Inspecting a request is more work than routing it, and this rule reads every header, cookie, and form or JSON field it sees. We measured it with wrk (an open-source HTTP load generator), 64 concurrent connections, 20 seconds per scenario, on the same 4-vCPU virtual machine that ran the gateway and the services. We measured 2 backends: the real Java service, and whoami, a tiny echo server that does almost no work and so shows the gateway's own cost at its largest.
| Traffic | Requests/s, no WAF | Requests/s, with WAF | Median latency, no WAF | Median latency, with WAF |
|---|---|---|---|---|
| GET to the Java service | 1,548 | 1,543 | 41.1 ms | 41.1 ms |
| POST 64-byte form to the Java service | 1,541 | 1,533 | 41.2 ms | 41.7 ms |
| POST 32 KB body to the Java service | 1,527 | 737 | 41.9 ms | 86.4 ms |
| GET to whoami | 8,004 | 6,238 | 7.4 ms | 9.6 ms |
| POST 32 KB body to whoami | 4,509 | 744 | 13.3 ms | 84.0 ms |
| POST 256 KB body to whoami | 3,164 | 114 | 19.2 ms | 533.7 ms |
| Java4Shell triggers, refused with 403 | 10,030 | 6.2 ms |
For the typical request to a real Java service, the cost is under 1%: a few kilobytes of headers and fields take the WAF far less time than the service takes to answer. The two backends also explain the gap between the Java and whoami rows. The Java service needs about 41 ms to answer each request under this load, so the WAF's work disappears inside that time. The whoami server, written in Go, answers in about 7 ms, so the same work is visible: GET throughput drops 22%, from 8,004 to 6,238 requests per second. The cost that remains is body size. The rule reads every request body in full, whatever it contains, so a 32 KB body halves the Java service's throughput and a 256 KB body to whoami loses 96%. That is a higher body-size cost than our PHP2Shell rule set showed, because that one mostly checked field names and lengths.
If you have endpoints that accept large request bodies of any kind, measure them before and after. If the cost is too high, the option we can stand behind is a separate route for those endpoints, with a deliberate decision about how they are protected until the JDK is updated. Do not lower SecRequestBodyLimit to skip the inspection: with the Reject action in this configuration, larger bodies are refused outright with a 413. The value printed here refuses any body above 12.5 MB, so check your largest legitimate upload before you attach the rule, and raise the limit on routes that need it. Attack requests, by contrast, are the cheapest traffic in the system: the gateway refused triggers at 10,030 per second, faster than it served legitimate requests, and the Java services never heard about them.
Set against unauthenticated remote code execution, a cost under 1% on ordinary traffic is an easy decision, and it ends when the JDK update lands.
For the Platform Team: The Configuration to Apply
This section is for the people who will do the work. Everything below is what ran in our test, printed as it ran. It targets Traefik Hub's native WAF middleware, which is configured with ModSecurity-compatible directives.
The Middleware object is the virtual patch. Apply it in the namespace of the IngressRoutes that front your Java services, replacing app with that namespace.
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
name: java4shell-virtual-patch
namespace: app
spec:
plugin:
coraza:
directives:
- SecRuleEngine On
- SecRequestBodyAccess On
- SecRequestBodyLimit 13107200
- SecRequestBodyInMemoryLimit 131072
- SecRequestBodyLimitAction Reject
# Parse every JSON media type (application/json, application/vnd.api+json, ...) so escaped characters are decoded before matching
- SecRule REQUEST_HEADERS:Content-Type "@rx (?i)[/+]json" "id:1004000,phase:1,pass,nolog,ctl:requestBodyProcessor=JSON"
- SecAction "id:1004001,phase:1,pass,nolog,ctl:forceRequestBodyVariable=On"
# Whole line = Base64 run of 64+ characters + malformed padding tail
- |-
SecRule REQUEST_HEADERS|REQUEST_COOKIES|REQUEST_COOKIES_NAMES|ARGS|ARGS_NAMES|REQUEST_BODY "@rx ^(?:[A-Za-z0-9+/_-]{4}){16,}(?:={1,3}|[A-Za-z0-9+/_-]={1,2}|[A-Za-z0-9+/_-]{2}=)$" "id:1004002,phase:2,t:none,deny,status:403,log,msg:'Java4Shell CVE-2026-114938 malformed Base64 padding',logdata:'%{MATCHED_VAR_NAME}',tag:'java4shell',tag:'CVE-2026-114938',severity:'CRITICAL'"
# The same shape in an Authorization header: any scheme (Basic, Bearer), or one dot-separated segment of a token
- |-
SecRule REQUEST_HEADERS:Authorization "@rx (?:^|[ \t.])(?:[A-Za-z0-9+/_-]{4}){16,}(?:={1,3}|[A-Za-z0-9+/_-]={1,2}|[A-Za-z0-9+/_-]{2}=)(?:\.|$)" "id:1004003,phase:2,t:none,deny,status:403,log,msg:'Java4Shell CVE-2026-114938 malformed Base64 in Authorization',logdata:'%{MATCHED_VAR_NAME}',tag:'java4shell',tag:'CVE-2026-114938',severity:'CRITICAL'"
# The same shape as one segment of the URL path
- |-
SecRule REQUEST_FILENAME "@rx (?:^|/)(?:[A-Za-z0-9+_-]{4}){16,}(?:={1,3}|[A-Za-z0-9+_-]={1,2}|[A-Za-z0-9+_-]{2}=)(?:/|$)" "id:1004004,phase:2,t:none,t:urlDecodeUni,deny,status:403,log,msg:'Java4Shell CVE-2026-114938 malformed Base64 in a path segment',logdata:'%{MATCHED_VAR_NAME}',tag:'java4shell',tag:'CVE-2026-114938',severity:'CRITICAL'"
# The same shape in a cookie whose value is percent-encoded
- |-
SecRule REQUEST_COOKIES "@rx ^(?:[A-Za-z0-9+/_-]{4}){16,}(?:={1,3}|[A-Za-z0-9+/_-]={1,2}|[A-Za-z0-9+/_-]{2}=)$" "id:1004005,phase:2,t:none,t:urlDecodeUni,deny,status:403,log,msg:'Java4Shell CVE-2026-114938 malformed Base64 in a percent-encoded cookie',logdata:'%{MATCHED_VAR_NAME}',tag:'java4shell',tag:'CVE-2026-114938',severity:'CRITICAL'"Attach it to every route that fronts a Java service by adding it to the route's middleware list:
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: my-java-app
namespace: app
spec:
entryPoints: [web]
routes:
- match: Host(`app.example.com`)
kind: Rule
middlewares:
- name: java4shell-virtual-patch # the WAF rules applied
services:
- name: my-java-app
port: 8080Then prove it from a shell with inert requests. The first and third commands must return 403. The second sends valid Base64 and must return whatever your service normally returns, anything but 403:
# trigger shape in a form field: must be refused
curl -s -o /dev/null -w '%{http_code}\n' --data "data=$(printf 'A%.0s' {1..64})=" https://app.example.com/api
# valid Base64 with correct padding: must pass
curl -s -o /dev/null -w '%{http_code}\n' --data "data=$(printf 'A%.0s' {1..64})AA==" https://app.example.com/api
# trigger shape as Basic credentials: must be refused
curl -s -o /dev/null -w '%{http_code}\n' -H "Authorization: Basic $(printf 'A%.0s' {1..64})=" https://app.example.com/api4 things we learned in testing that you should know before you ship it:
- Run the engine in blocking mode (
SecRuleEngine On). In detection-only mode the trigger is logged and still reaches the JVM. - The rule matches a whole line of a field's value. That is what removed the false positives on valid Base64, and it is also the rule's main limit. These shapes are not caught: a trigger after a prefix inside one field (
v1:followed by the trigger, for an application that splits the value before decoding), a trigger followed by a line break for a service that uses Java's MIME decoder, a trigger inside an uploaded file, and a trigger in a WebSocket message. If your applications decode Base64 from any of these, tell us, and test that shape before you rely on the rule. - Measure large-body endpoints before and after, as described in the previous section.
- Make the gateway the only way in. Add a NetworkPolicy so the Java pods accept traffic only from the gateway's namespace. A WAF on the route does nothing for a request that bypasses the route, and it does nothing for Base64 that a service reads from a queue, a file, or another internal source.
A Stopgap, Not the Remediation
The limits matter as much as the results. A virtual patch blocks request shapes known today. The flaw remains in every unpatched JVM behind the gateway. If someone finds another way to deliver the trigger, such as a format that a service decodes into Base64 before passing it on, the rule has a hole, and the service behind it is as exposed as it was on November 16. We will update the rule as new shapes are published, but a rule set always describes the attacks we have seen.
There are also paths the gateway does not see. Traffic that reaches a Java service without passing through the gateway, from another workload in the cluster, from a message queue, or from a batch job that reads files, is not filtered. The rule protects only the routes it is attached to.
Use the virtual patch to buy time, and spend that time on the update. Our suggested sequence:
- Today: attach the virtual patch to every route that fronts a Java service, in blocking mode. Confirm with the test requests above that the trigger returns 403 and valid Base64 passes.
- This week: inventory every JVM you operate or buy, including container base images and vendor products, and note which run on AVX-512 VBMI hardware. Where a restart is cheap, add
-XX:-UseBASE64Intrinsicsnow. - As each update lands: move to a fixed JDK build (Oracle shipped 17.0.21.1, 21.0.13.1, 25.0.5.1, and 27.0.1.1 on November 17; check your distribution for its own numbers) and restart.
- After the fleet is patched: keep the rule if its cost is acceptable on your traffic. It is cheap for typical requests, and the next decoder bug could look similar.
The risk after any emergency rule is that it works well enough for the real fix to slip from this sprint to next quarter. Whoever approves the virtual patch should approve the JDK update date in the same meeting.
What to Do in the Next Hour
If you run Java services on recent Intel or AMD servers, you are in the window right now. Send this post to the team that owns your gateway and ask for 2 things by the end of the day: the virtual patch attached in blocking mode to every Java route, and a dated plan for the JDK update.
If you already run Traefik Hub, the configuration above is all you need. If you do not, the WAF is part of the standard Hub distribution: get in touch with us, and we will help you put it in front of your Java services this week. If you use another gateway with a ModSecurity-compatible WAF, the same rules should translate with little effort. We cannot guarantee how they behave on another vendor's engine, so test them there first, with the same false-positive checks we ran.
Put the rule in front of your Java services today, and keep it there until every JVM behind it runs a fixed build.




