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:
[email protected]
For queries about this service, please contact Infrastructure at:
[email protected]