11-19 更新 实时
首页/ 技术栈/ 正文

Cloudflare WAF 如何防御 Java4Shell(CVE-2026-114938)

技术栈 来源:Cloudflare Blog 2026-11-18 22:52 0 阅读 机器翻译
Cloudflare WAF 如何防御 Java4Shell(CVE-2026-114938)

2026 年 11 月 17 日,安全研究公司 Calif 披露了 Java4Shell(CVE-2026-114938),这是 OpenJDK——使用最广泛的 Java 运行时——的 Base64 解码器中的一个内存破坏漏洞。按照通用漏洞评分系统(CVSS)4.0,其评分为 10 分制下的 9.2 分,属严重级别。该漏洞影响 Java。OpenJDK 发布了安全公告,Oracle 也在同日 21:00 UTC 发布的 2026 年 11 月关键补丁更新(Critical Patch Update)中放出了已修复的构建版本。

该漏洞使无需任何凭据的远程攻击者能够向 Java 应用发送畸形的 Base64 数据,并覆写解码输出相邻的内存。Calif 将这种覆写转化为堆内存泄露(类似 Heartbleed),以及远程代码执行。Calif 演示了针对 Keycloak、Atlassian Jira、Atlassian Confluence、JFrog Artifactory、Jenkins 和 PingFederate 默认配置的预认证远程代码执行,以及针对 Apache Kafka、Apache Solr、Elasticsearch、Gerrit 和 Spinnaker 的认证后远程代码执行。

Cloudflare 在 Cloudflare Managed Ruleset 中发布了一组新规则,旨在检测与该漏洞相关的畸形 Base64 输入模式。这些规则在 Pro、Business 和 Enterprise 套餐中可用,并默认启用,动作为 Log(记录),因为畸形输入以及某些应用特有的良性 Token 格式可能与利用尝试相似。因此,默认拦截可能会干扰正常流量。客户现在可以在 Security Events 中查看匹配的请求,一旦确认不影响正常流量,即可将规则动作改为 Block(拦截)。

WAF 是一层额外的防御,而非补丁的替代品。Java4Shell 可以通过 WAF 看不到的路径触达,例如出站 TLS 响应,唯一彻底的修复办法是更新 Java 运行时。我们的分析师持续监控攻击活动,并会在出现新手法和新变种时更新规则。你可以在 WAF 变更日志中跟踪规则变化,并在专门的 Cloudflare Zero Wire 简报中了解该漏洞的更多进展。

到目前为止,我们尚未发现任何迹象表明 Java4Shell 在 Cloudflare 基础设施上被利用。

Base64 是一种将二进制数据表示为文本的常见方式。Java 应用在处理认证头、Token、文件上传以及许多网络消息时会解码 Base64。为了更快地解码,OpenJDK 会用专门的机器码(称为 intrinsics)替换频繁使用的代码。在受支持的 x86-64 处理器上,Base64 intrinsic 使用 AVX-512 指令,一次处理 64 字节。

该 bug 位于处理输入末尾字符的手写汇编代码中。当输入尾部在合法 Base64 绝不会放置填充字符(=)的位置出现填充字符时,该例程会计算出一个负的输出长度。这个非法长度会变成一次完整的 64 字节写入。对于由 64 个字符后跟一个 = 组成的 65 字符输入,OpenJDK 会分配一个 50 字节的输出数组,然后在其末尾之后写入 62 字节。

Java 最终会判定该输入无效并抛出异常。但到那时,相邻内存已经被覆写。应用自身的输入校验也无济于事,因为损坏发生在解码器内部,应用还来不及拒绝这些数据。

最简单的触发条件是 64 个 A 字符后跟一个 =。在 OpenJDK 17 上,触发需要 128 个字符后跟 =,因为快速代码路径的阈值更高。

利用并非指哪打哪。被覆写的字节大多是固定值,攻击者只能控制写入的落点。要构建可用的利用程序,Calif 对 Java 堆进行了布局,使溢出扩大相邻数组,从而先获得读取堆内存的能力,再获得写入指定字节的能力。每个目标应用都需要各自的利用链。Calif 报告称,在 AI 智能体的帮助下,其首个可用的本地利用程序约用三小时开发完成,因此我们预计其他攻击者也会快速构建出利用链。

Java4Shell 只有在以下所有条件都成立时才会影响系统:

Java 运行时

OpenJDK 17.0.6 或更新版本,包括基于 OpenJDK 构建的各发行版:Amazon Corretto、Eclipse Temurin、Microsoft Build of OpenJDK、Azul Zulu、BellSoft Liberica、SAP SapMachine、Red Hat OpenJDK、Oracle OpenJDK、Oracle Java SE 以及面向 JDK 的 Oracle GraalVM。受影响 Oracle 构建版本的准确列表请查阅 Oracle 的安全公告。

支持 AVX-512 VBMI 的 x86-64,例如 Intel Xeon Ice Lake、Sapphire Rapids、Emerald Rapids 和 Granite Rapids,或 AMD EPYC 与 Ryzen Zen 4 及更新版本。ARM64 处理器不受影响。

应用使用标准 Java 解码器解码由攻击者控制的 Base64 数据。

许多应用自带 Java 运行时,容器镜像也会附带固定的 Java Development Kit(JDK)。升级系统 Java 软件包不会更新这些副本,也不会替换已在运行的 Java 虚拟机(JVM)。每个更新后的服务都需要重启。

如果你无法立即更新,Calif 记录了两个 JVM 启动参数,可移除存在漏洞的代码路径:

这两个参数都需要重启,并且可能会降低需要解码大量 Base64 的工作负载的性能。它们只是为你打补丁争取时间,并不能替代更新。

为每个 Java 运行时打补丁需要时间,尤其是当 JDK 被捆绑在应用程序和容器镜像内部时。Cloudflare WAF 可以在你打补丁期间降低暴露风险。一条新的托管规则已在付费套餐中提供,并默认以 Log 模式启用,可检测触发 Java4Shell 的畸形 Base64 输入。对于 Business 和 Enterprise 客户,WAF 攻击评分增加了一层机器学习能力,会对每个请求的远程代码执行载荷进行评分,有助于捕获基于签名的规则可能漏掉的变体和绕过尝试。

付费套餐的防护已作为 Cloudflare Managed Ruleset(Ruleset ID efb7b8c949ac4650a09736fc376e9aee)的一部分发布。该规则默认启用,动作为 Log,因为默认拦截可能会对合法的 Base64 流量造成误报。要查看其匹配情况,请前往 Security > Security Analytics > Events,并按规则 ID 筛选。如果匹配到的并非合法流量,请将该规则动作改为 Block:前往 Security > Settings,编辑 Cloudflare Managed Ruleset,搜索 CVE-2026-114938,并将该规则动作设为 Block。或者,你也可以点击链接,在 Zero Wire 简报中查看你的配置。

规则说明

Java4Shell - 畸形 Base64 请求头 - CVE-2026-114938

5de9b20a45ea45d3841919ab4d718bf4

Java4Shell - 畸形 Base64 查询参数值 - CVE-2026-114938

46bb4172813e471ea62d31c02337b51d

Java4Shell - 畸形 Base64 请求体值 - CVE-2026-114938

d4dc3f71f1bc44a0811ae570e5e5836c

Java4Shell - 畸形 Base64 路径段 - CVE-2026-114938

0dceaf0684b54fd0b085fcfb6fd6f152

Java4Shell - 畸形 Base64url JWT 组件 - CVE-2026-114938

0ddd0eb664a040779f2f19065a25d991

Java4Shell - 畸形 Base64 WebAuthn 值 - CVE-2026-114938

4fce1ea79a614c07a27348d167d74ebb

我们正在为 Cloudflare Free Managed Ruleset 制定一条规则,规则可用后我们将更新本文。

当畸形的 Base64 经由穿过 Cloudflare 的 HTTP 请求到达时,WAF 能够阻断该漏洞利用。但它无法阻断通往存在漏洞的解码器的所有路径,包括:

虽然托管规则是在边缘阻断畸形 Base64 触发的主要方式,但 Cloudflare WAF Attack Score(具体而言是其远程代码执行子评分 cf.waf.score.rce,企业版计划可用)可以提供额外的、互补的防护层。

由于 CVE-2026-114938(Java4Shell)是一个二进制堆破坏漏洞,攻击者仅凭单个 65 字节(或 129 字节)的触发字符串,很少能实现完整且可靠的远程代码执行。在线路上,该初始触发看起来像是一个不透明的、畸形的 Base64 字符串,其中包含堆破坏字节,而非传统的 Web 层注入语法。因此,基于应用层注入模式训练的机器学习模型不会单独标记原始的 Base64 触发字符串。

相反,要把一次有界的 JVM 堆溢出通过 HTTP 转化为远程代码执行,几乎总是需要多阶段或多参数的漏洞利用链,这会产生更多可供 WAF Attack Score 检查并标记的指纹,包括:

由于复杂的内存内漏洞利用仍然可以在完全不通过 HTTP 发送明文 shell 命令的情况下执行原始 shellcode 或操纵字节码,WAF Attack Score 应与显式的 Base64 规则和 JVM 补丁配合使用。

你可以在我们的 WAF 指南中找到有关如何部署托管规则和攻击评分的更多信息,但简而言之:

原文较长,译文为节选;译文由英文原文机器翻译,术语按行业惯例统一,可在文末展开原文核对。

查看英文原文(How Cloudflare WAF helps protect against Java4Shell (CVE-2026-114938))

On November 17, 2026, the security research company Calif disclosed Java4Shell (CVE-2026-114938), a memory-corruption vulnerability in the Base64 decoder of OpenJDK, the most widely used Java runtime. Under the Common Vulnerability Scoring System (CVSS) 4.0, it scores 9.2 out of 10 (Critical). The flaw affects Java. OpenJDK published a security advisory and Oracle released patched builds in its November 2026 Critical Patch Update the same day, at 21:00 UTC.

The vulnerability lets a remote attacker with no credentials send malformed Base64 data to a Java application and overwrite memory next to the decoded output. Calif turned that overwrite into a leak of heap memory, similar to Heartbleed, and into remote code execution. Calif demonstrated pre-authentication remote code execution against Keycloak, Atlassian Jira, Atlassian Confluence, JFrog Artifactory, Jenkins and PingFederate in their default configurations, and post-authentication remote code execution against Apache Kafka, Apache Solr, Elasticsearch, Gerrit, and Spinnaker.

Cloudflare has released a new set of rules in the Cloudflare Managed Ruleset designed to detect malformed Base64 input patterns associated with this vulnerability. The rules are available on Pro, Business and Enterprise plans and are enabled by default with the Log action because malformed input and some benign application-specific token formats can resemble exploitation attempts. Blocking by default could therefore disrupt legitimate traffic. Customers can review matching requests in Security Events now and change the rules action to Block once they confirm it does not affect legitimate traffic. 

The WAF is an additional layer of defense, not a replacement for the patch. Java4Shell can be reached through paths a WAF does not see, like outbound TLS responses, and the only complete fix is to update the Java runtime. Our analysts continue to monitor attack activity and will update the rules as new techniques and variations appear. You can track rule changes in the WAF changelog and get more information on how the vulnerability develops on the dedicated Cloudflare Zero Wire briefing.

We have seen no indication so far that Java4Shell was exploited on Cloudflare infrastructure.

What we know about the vulnerability

Base64 is a common way to represent binary data as text. Java applications decode Base64 when they process authentication headers, tokens, file uploads and many network messages. To decode it faster, OpenJDK replaces frequently used code with specialized machine code, called intrinsics. On supported x86-64 processors, the Base64 intrinsic uses AVX-512 instructions to process 64 bytes at a time.

The bug sits in the handwritten assembly that handles the final characters of the input. When the tail of the input contains padding characters (=) in a position where valid Base64 never places them, the routine calculates a negative output length. That invalid length turns into a full 64-byte write. For a 65-character input, made of 64 characters followed by a single =, OpenJDK allocates a 50-byte output array and then writes 62 bytes past its end.

Java eventually rejects the input as invalid and throws an exception. By then, the neighboring memory has already been overwritten. An application's own input validation does not help, because the corruption happens inside the decoder before the application can reject the data.

The simplest trigger is 64 A characters followed by =. On OpenJDK 17, the trigger needs 128 characters followed by =, because the threshold for the fast code path is higher.

Exploitation is not point-and-shoot. The overwritten bytes are mostly fixed values, and the attacker controls only where the write lands. To build a working exploit, Calif arranged the Java heap so that the overflow enlarged neighboring arrays, which gave them first a way to read heap memory and then a way to write chosen bytes. Each target application requires its own exploit chain. Calif reported developing its first working local exploit in about three hours with the help of AI agents, so we expect other attackers to build exploit chains quickly.

Who is affected

Java4Shell affects a system only when all the following conditions are true:

Condition

Details

Java runtime

OpenJDK 17.0.6 or newer, including distributions built from OpenJDK: Amazon Corretto, Eclipse Temurin, Microsoft Build of OpenJDK, Azul Zulu, BellSoft Liberica, SAP SapMachine, Red Hat OpenJDK, Oracle OpenJDK, Oracle Java SE and Oracle GraalVM for JDK.

Check Oracle's advisory for the exact list of affected Oracle builds.

Processor

x86-64 with AVX-512 VBMI support, such as Intel Xeon Ice Lake, Sapphire Rapids, Emerald Rapids and Granite Rapids, or AMD EPYC and Ryzen Zen 4 or newer. ARM64 processors are not affected.

Input

The application decodes attacker-controlled Base64 data with the standard Java decoder.

Many applications bundle their own Java runtime, and container images ship with a fixed Java Development Kit (JDK). Upgrading the system Java package does not update those copies, and it does not replace a Java virtual machine (JVM) that is already running. Every updated service needs a restart.

Mitigate if you cannot patch right away

If you cannot update immediately, Calif documents two JVM startup flags that remove the vulnerable code path:

  • -XX:-UseBASE64Intrinsics disables hardware-accelerated Base64 encoding and decoding.
  • -XX:UseAVX=2 disables AVX-512. Apply this flag only on x86-64 hosts. OpenJDK on ARM does not recognize it and will fail to start.

Both flags require a restart and may reduce performance for workloads that decode large amounts of Base64. They buy time while you patch. They do not replace the update.

Protect your infrastructure while you patch

Patching every Java runtime takes time, especially when JDKs are bundled inside applications and container images. Cloudflare WAF can reduce your exposure while you patch. A new managed rule, available on paid plans and enabled in Log mode by default, detects the malformed Base64 input that triggers Java4Shell. For Business and Enterprise customers, WAF attack score adds a machine learning layer that scores each request for remote code execution payloads, which helps catch variations and bypass attempts that signature-based rules can miss.

New managed rules

Protection for paid plans has been released as part of the Cloudflare Managed Ruleset (Ruleset ID efb7b8c949ac4650a09736fc376e9aee). The rule is enabled by default with the Log action, because blocking by default could cause false positives on legitimate Base64 traffic. To review its matches, go to Security > Security Analytics > Events and filter by the rule ID. If the matches are not legitimate traffic, change the rule action to Block: go to Security > Settings, edit the Cloudflare Managed Ruleset, search for CVE-2026-114938 and set the rule action to Block. Alternatively, you can follow the link to review your configuration on the Zero Wire briefing.

Rule description

Rule ID

Java4Shell - Malformed Base64 Header - CVE-2026-114938

5de9b20a45ea45d3841919ab4d718bf4

Java4Shell - Malformed Base64 Query Value - CVE-2026-114938

46bb4172813e471ea62d31c02337b51d

Java4Shell - Malformed Base64 Body Value - CVE-2026-114938

d4dc3f71f1bc44a0811ae570e5e5836c

Java4Shell - Malformed Base64 Path Segment - CVE-2026-114938

0dceaf0684b54fd0b085fcfb6fd6f152

Java4Shell - Malformed Base64url JWT Component - CVE-2026-114938

0ddd0eb664a040779f2f19065a25d991

Java4Shell - Malformed Base64 WebAuthn Value - CVE-2026-114938

4fce1ea79a614c07a27348d167d74ebb

We are working on a rule for the Cloudflare Free Managed Ruleset and will update this post when it is available.

A WAF can block the exploit when the malformed Base64 arrives in an HTTP request that passes through Cloudflare. It cannot block every path to the vulnerable decoder, including:

  • Encoded or nested data. The Base64 value may be wrapped inside another encoding or compressed format that the application unpacks before decoding.
  • Non-HTTP protocols. Some affected products, such as the Apache Kafka broker, accept traffic over their own protocols.
  • Outbound connections. Calif also shared a client-side exploit: a Java program that opens a TLS connection to a malicious server can be compromised, even if it exposes no service of its own.
  • Traffic that bypasses Cloudflare. This includes internal traffic between services.

Adding defense-in-depth with WAF attack score

While the managed rule is the primary way to block malformed Base64 triggers at the edge, Cloudflare WAF Attack Score (and specifically its remote code execution sub-score cf.waf.score.rce available on Enterprise plans) can offer an additional, complementary layer of protection.

Because CVE-2026-114938 (Java4Shell) is a binary heap-corruption vulnerability, an attacker rarely achieves full, reliable remote code execution with a single 65-byte (or 129-byte) trigger string alone. On the wire, that initial trigger looks like an opaque, malformed Base64 string containing heap-corruption bytes rather than traditional web-layer injection syntax. As a result, machine learning models trained on application-layer injection patterns will not flag the raw Base64 trigger in isolation.

Instead, turning a bounded JVM heap overflow into remote code execution over HTTP almost always requires a multi-stage or multi-parameter exploit chain, which creates more fingerprints that WAF Attack Score can inspect and flag, including:

  • Heap Grooming and Triggering: To corrupt a predictable adjacent object on the JVM heap (such as a String or byte[] length header), attackers often send repetitive parameters or headers alongside the malformed Base64 payload to shape memory layout before triggering the out-of-bounds write.
  • Second-Stage Payloads: Once heap corruption gives the attacker control over execution flow or object references, the exploit still needs commands, scripts, or Java gadgets to run. If an exploit chain pairs the initial heap-corruption trigger with a second-stage payload such as shell execution primitives (/bin/sh -c, cmd.exe, reverse-shell strings) or Java class-loading gadgets (java.lang.Runtime, ProcessBuilder, serialized object streams) tucked into another header, query parameter, or request body, cf.waf.score.rce can detect and score that secondary payload as malicious.
  • Post-Exploitation Activity: Even if an initial heap-read or corruption request slips past edge filters, subsequent HTTP requests attempting to interact with an in-memory webshell or pass OS commands to the compromised JVM remain directly visible to WAF Attack Score.

Deploy protections and patch

Because sophisticated in-memory exploits can still execute raw shellcode or manipulate bytecode without ever sending plaintext shell commands over HTTP, WAF Attack Score should be used alongside explicit Base64 rules and JVM patching.

You can find more information on how to deploy Managed rules and attack score in our WAF guide, but in a nutshell:

1. Set the CVE-2026-114938 rule in the Cloudflare Managed Ruleset (Pro plan and above) to Block. It is enabled in Log mode by default, so review its matches in Security Events first. Use the links on the Cloudflare Zero Wire page to review your rules status.

2. Layer Attack Score to get ML-based remote code execution (RCE) detection: create a custom rule blocking or challenging requests with a low RCE attack score (for example, cf.waf.score.rce le 20 on Enterprise plans, or cf.waf.score.class eq "attack" on Business plans) to catch multi-stage exploit chains and post-exploitation command traffic.

3. Remediate at runtime: Upgrade to patched OpenJDK builds (or set -XX:+UnlockDiagnosticVMOptions -XX:-UseBASE64Intrinsics as a temporary workaround) to eliminate the vulnerable AVX-512 code path entirely. Follow the OpenJDK advisory and Oracle's Critical Patch Update and install your Java vendor's fixed release as soon as possible. For a prompt you can give an AI agent to inventory your Java runtimes, see the Java4Shell page on Cloudflare Zero Wire. 

Impact on Cloudflare infrastructure

Cloudflare also runs Java, so when Java4Shell was disclosed we checked our own systems. The vulnerability can only be triggered in specific hardware configurations, namely a x86-64 processor that supports AVX-512 VBMI, so a system is exposed only when both are true. Our investigation found that the majority of our Java workloads are not scheduled on vulnerable systems; we took immediate action to protect the remainder.

About an hour after the patches were published, we began rolling out a JVM startup option that turns off the accelerated Base64 routine containing the bug on all Java workloads, so decoding falls back to the standard implementation. To be safe, we are rolling out our patched configuration to all machines, regardless of hardware as a precaution. We have seen no indication so far that Java4Shell was exploited on Cloudflare infrastructure.

Update every Java runtime now

Java4Shell turns a performance optimization in the Java runtime into a path to remote code execution, and with technical details now public, we expect exploit attempts to follow quickly. The fix is to update every Java runtime and restart the services that use it. While you patch, review the new managed rule's matches and switch it to Block if you are on a paid plan and use attack score to catch remote code execution payloads that signatures may miss. 

Our WAF analysts will continue to update protections as new techniques emerge. Follow the WAF changelog for rule updates and the Java4Shell page on Cloudflare Zero Wire for the latest on this vulnerability.

正文保留英文原文,标题与摘要由机器翻译。

本文由采集器自动同步

原文发布于 Cloudflare Blog(How Cloudflare WAF helps protect against Java4Shell (CVE-2026-114938)),标题、摘要与正文由机器翻译,术语按行业惯例统一,未经人工逐句校订。

阅读原文 ↗