You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "AlvaroNeovia (via GitHub)" <gi...@apache.org> on 2026/09/22 23:13:16 UTC

[I] [Security] Incomplete fix of CVE-2022-31764 in ElasticJob UI - arbitrary JDBC URL via whitelisted drivers (H2 INIT -> RCE) [shardingsphere-elasticjob]

AlvaroNeovia opened a new issue, #2542:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/2542

   Hi,
   
   The following is the result of a read-only security review; all reproduction was done in a DISPOSABLE environment. Happy to provide PoCs / verification details on request.
   
   ---
   
   ## A. 上游通知(`apache/shardingsphere-elasticjob-ui`)
   
   **主题**:CVE-2022-31764 的修复仅增加 **JDBC driver 类名白名单**,但 **JDBC URL 完全不受约束** —— 通过白名单的任一 driver(官方示例即含 `org.h2.Driver` / `org.postgresql.Driver`)仍可令服务端向**任意 `host:port`** 发起 JDBC 连接(协议层数据外发)——原危害面(恶意 JDBC URL)在白名单配置下**依旧可达**。
   
   ### A.1 修复机制(当前代码)
   
   ```java
   // EventTraceDataSourceController(3.1.0-SNAPSHOT)
   @PostMapping("/connectTest") → failedIfDriverClassNotAllowed(config.getDriver());   // ← 唯一校验:driver 类名
                               → setDataSourceNameToSession(config, session);
                               → EventTraceDataSourceFactory.createEventTraceDataSource(driver, url, user, pass); // URL 直入建连
   // 白名单配置:dynamic.datasource.allowed-driver-classes(默认注释=空集;启用时由部署方配置,示例={'org.h2.Driver','org.postgresql.Driver'})
   ```
   
   **缺口**:白名单是"**允许哪些 driver**"的清单,**不是"允许连接哪些 URL"的清单**——任何白名单内 driver 的 URL(`host:port`/参数)均未校验。
   
   ### A.2 运行时实证(本地 lab,全部回环)
   
   | # | 测试 | 结果 |
   |---|---|---|
   | 1 | 对照:driver=非白名单(`evil.Driver`) | **被拒**("Please add 'evil.Driver' to [dynamic.datasource.allowed-driver-classes]")⇒ driver 白名单**有效** |
   | 2 | 对照:白名单 driver + 无害 URL | `success:true` |
   | 3 | **H2 驱动路径**:`jdbc:h2:tcp://127.0.0.1:<LISTENER>/nope` | 本地监听器 **ACCEPT** + `RECV 144B`(含目标库名与 `jdbc:h2:tcp:` 明文,UTF-16) |
   | 4 | **PG 驱动路径**(42.4.1):`jdbc:postgresql://127.0.0.1:<LISTENER>/probe` | 本地监听器 **ACCEPT** + **`RECV 8B`=PG `SSLRequest`(`00000008` + 魔数 `04d2162f`)** |
   
   ⇒ **两条独立 driver 路径均实证"任意 host:port 连接 + 应用层协议数据外发"**。
   
   ### A.3 修复建议
   
   1. **URL 白名单/黑名单**:对 `connectTest`/`add` 的 URL 增加校验(至少:**限制 host 为用户显式配置过的数据库清单**、禁止 `tcp://`/远程地址形态、或按部署启用"仅本机/内网段"规则);
   2. **权限模型**:该功能(动态数据源)应仅限**管理员显式启用**并有操作审计(当前为默认凭据登录即可达);
   3. **文档明示**:白名单属性旁注明"仅约束 driver 类名,不约束 URL 目标"——提醒部署方该功能等价于**服务端任意 JDBC 连接能力**;
   4. (纵深)对 `loggerFile` 等 URL 参数做显式禁用清单——**本 lab 中未复现其文件写效果**(如实),但同类参数面建议统一收紧。
   
   ---
   
   
   ---
   
   *(Security hardening request; full technical annex available on request.)*
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Security] Incomplete fix of CVE-2022-31764 in ElasticJob UI - arbitrary JDBC URL via whitelisted drivers (H2 INIT -> RCE) [shardingsphere-elasticjob]

Posted by "AlvaroNeovia (via GitHub)" <gi...@apache.org>.
AlvaroNeovia commented on issue #2542:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/2542#issuecomment-5787134811

   **Follow-up: the H2 `INIT` channel reaches code execution under the same whitelist configuration (verified in lab)**
   
   The title mentions "H2 INIT -> RCE" — adding the verification detail here, since it raises the impact of the incomplete fix beyond server-side TCP:
   
   - **Path**: `POST /api/data-source/connectTest` → `driver=org.h2.Driver` (the whitelist example) → `url=jdbc:h2:mem:x;INIT=CREATE ALIAS IF NOT EXISTS E AS '<java source>'\;CALL E()`
   - **Result**: `{"success":true}` returned; the alias executes with the OS privileges of the UI process (in our disposable lab: `uid=0`, proof file captured — happy to share).
   - **Reproduction gotcha**: a bare `;` inside the `INIT` value truncates the H2 URL parse (`URL format error ... 90046-196`); escaping as `\;` makes the channel work. This is the failure mode most reviewers hit first.
   - **Why the driver whitelist is not a fix for this**: the whitelist constrains *which driver class* may load, not the *URL semantics*. Any whitelisted driver exposing URL-scriptable behaviour (H2 `INIT` incl. `CREATE ALIAS` / `RUNSCRIPT FROM` / JNDI) yields code execution; drivers without such features still yield raw TCP/data exfiltration (as reported).
   
   Reply here if a full PoC package (request body, expected responses, proof-of-exec output) would help.
   
   ---
   
   *(Same disposable-lab conditions as the original report; no third-party systems touched.)*
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Security] Incomplete fix of CVE-2022-31764 in ElasticJob UI - arbitrary JDBC URL via whitelisted drivers (H2 INIT -> RCE) [shardingsphere-elasticjob]

Posted by "linghengqian (via GitHub)" <gi...@apache.org>.
linghengqian commented on issue #2542:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/2542#issuecomment-5787539000

   - We lack maintainers for shardingsphere-elasticjob-ui. Shardingsphere-elasticjob-ui is no longer compatible with the project's current main branch.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org