Files
hzdyjs/问题整改/SQL注入漏洞整改说明-tenantId.md
2026-09-22 19:22:18 +08:00

41 lines
1.6 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# SQL 注入漏洞整改说明(tenantId / P5)
## 背景
攻防演练报告:免登接口 `POST /prod-api/auth/register` 的 `tenantId` 经多租户插件拼入 SQL,可 `extractvalue` 拖库(RuoYi-Vue-Plus XVE-2026-50962 同类问题)。
## 整改措施(代码已落地)
| # | 措施 | 位置 |
|---|------|------|
| 1 | sink 白名单:租户 ID 仅 `^[0-9]{1,20}$`,非法不拼 SQL | `PlusTenantLineHandler`、`TenantHelper.checkTenantIdFormat` |
| 2 | 注册接口先 `checkTenant`,再查注册开关 | `AuthController.register` |
| 3 | 登录/动态租户入口统一格式校验 | `SysLoginService.checkTenant`、`TenantHelper.setDynamic` |
| 4 | 入参 Bean 校验 `@Pattern` | `LoginBody.tenantId`(含注册) |
| 5 | `selectRegisterEnabled` 入口再校验 | `SysConfigServiceImpl` |
| 6 | 社交登录绑定参数校验 | `AuthController.authBinding` |
| 7 | 删除心理咨询调试任意 SQL 接口 | 已删除 `XljkConsultationDebugController` |
## 配套 SQL(生产建议执行)
关闭开放注册,缩小免登攻击面:
```sql
UPDATE sys_config
SET config_value = 'false',
update_time = NOW()
WHERE config_key = 'sys.account.registerUser'
AND deleted = 0;
```
## 发布与验证
1. 重新编译发布 **backend**(仅发前端无效)
2. 用报告同类 payload 打 `/prod-api/auth/register`,应返回租户编号格式不正确 / 未开启注册,**不应**再出现 XPATH / SQL 报错泄密
3. 正常 `tenantId=000000` 登录不受影响
## 状态
- 代码:已完成
- 生产生效:取决于是否已用含本修复的包重启