From 9d73ff019cb86e602e326aac916b084289dfd474 Mon Sep 17 00:00:00 2001 From: Jokul Date: Sun, 12 Jul 2026 14:13:44 +0800 Subject: [PATCH] fix(security): patch all P0 vulnerabilities from project review - credential: encrypt/decrypt now throw when safeStorage unavailable instead of base64 fallback - ipc-handlers: encrypt auth/sshPassword/sshPassphrase before storing, decrypt on read (avoid mutation) - ipc-handlers: block FLUSHALL/FLUSHDB/SHUTDOWN/DEBUG in redis:execute, add redis:executeUnsafe for CLI - format: whitelist allowed external formatters (xxd/jq/python3/python/php/column), clean up tmpDir - connection: clearTimeout on ready/error paths to fix timeout race in Sentinel/Cluster/normal modes - index: add app.on('will-quit') to disconnectAll + stopAllPubSubClients on exit - pubsub: add stopAllPubSubClients() to clean up all sub/monitor connections - docs: add PROJECT_REVIEW.md with full audit report and fix status --- docs/PROJECT_REVIEW.md | 209 ++++++++++++++++++ src/main/credential.ts | 5 +- src/main/index.ts | 7 + src/main/ipc-handlers.ts | 53 ++++- src/main/redis/connection.ts | 15 +- src/main/redis/format.ts | 18 +- src/main/redis/pubsub.ts | 9 + src/preload/index.d.ts | 1 + src/preload/index.ts | 2 + src/renderer/src/components/views/CliView.vue | 12 +- .../src/components/views/StatusView.vue | 2 +- 11 files changed, 314 insertions(+), 19 deletions(-) create mode 100644 docs/PROJECT_REVIEW.md diff --git a/docs/PROJECT_REVIEW.md b/docs/PROJECT_REVIEW.md new file mode 100644 index 0000000..fb6b71c --- /dev/null +++ b/docs/PROJECT_REVIEW.md @@ -0,0 +1,209 @@ +# JRedisDesktop 项目审查报告 + +> 审查日期:2026-07-12 +> 审查方式:并行扫描主进程、渲染进程、IPC 契约一致性 +> 审查范围:主进程 10 文件、渲染进程 ~40 文件、IPC 65 通道 +> 发现问题:54 个(P0×6, P1×12, P2×17, P3×19) +> 已修复:**P0×6 全部修复** (2026-07-12) +> 可开发需求:26 项(高优先级 6,中 11,低 9) + +--- + +## 目录 + +- [一、缺陷清单(按优先级)](#一缺陷清单按优先级) +- [二、系统性架构问题](#二系统性架构问题) +- [三、可开发需求清单(按优先级)](#三可开发需求清单按优先级) +- [四、修复路线图建议](#四修复路线图建议) +- [五、关键数据](#五关键数据) + +--- + +## 一、缺陷清单(按优先级) + +### P0 - 必须立即修复(安全/数据丢失) — 全部已修复 + +| # | 位置 | 问题 | 状态 | +|---|------|------|------| +| 1 | `src/main/ipc-handlers.ts:55-62` | **凭据明文存储**:`storage:saveConnection` 加密 auth/sshPassword/sshPassphrase (enc: 前缀);`storage:getConnections` 读取时解密 | **已修复** | +| 2 | `src/main/redis/format.ts:51-79` | **命令注入**:新增 `ALLOWED_FORMATTERS` 白名单(xxd/jq/python3/python/php/column),不在白名单则拒绝执行 | **已修复** | +| 3 | `src/main/ipc-handlers.ts:105-121` | **无命令白名单**:新增 `BLOCKED_COMMANDS` (FLUSHALL/FLUSHDB/SHUTDOWN/DEBUG);`redis:execute` 拦截危险命令;新增 `redis:executeUnsafe` 供 CLI 绕过 | **已修复** | +| 4 | `src/main/index.ts:67-70` | **退出无清理**:新增 `app.on('will-quit')` 调用 `disconnectAll()` + `stopAllPubSubClients()` | **已修复** | +| 5 | `src/main/redis/connection.ts` (3处) | **超时竞态**:Sentinel/Cluster/普通模式的 setTimeout 均保存 timer ID,在 ready/error 路径调用 clearTimeout | **已修复** | +| 6 | `src/main/credential.ts:4-5` | **safeStorage 不可用时回退明文**:encrypt/decrypt 在 safeStorage 不可用时抛出错误,decrypt catch 保留 base64 兼容旧数据并加 console.warn | **已修复** | + +### P1 - 严重 Bug(功能错误) + +| # | 位置 | 问题 | +|---|------|------| +| 7 | `CliView.vue:52-101` | **MULTI/EXEC 事务逻辑错误**:事务模式下每条命令仍通过 IPC 单独发送到 Redis,服务器立即执行而非排队。完全破坏事务语义。应本地排队,EXEC 时 pipeline 一次性发送。 | +| 8 | `KeyDetail.vue:43-68` | **TTL 定时器模块级泄漏**:`setInterval` 在 `