Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions SECURITY_AUDIT_REPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# 项目全面审计报告

## 执行摘要

| 审计类型 | 严重问题 | 中等问题 | 轻微问题 | 总计 |
|----------|----------|----------|----------|------|
| 安全审计 | 5 | 3 | 4 | 12 |
| Bug查找 | 2 | 9 | 4 | 15 |
| 代码质量 | 5 | 4 | 7 | 16 |
| 性能分析 | 0 | 8 | 4 | 12 |
| **总计** | **12** | **24** | **19** | **55** |
Comment on lines +1 to +11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

No GitHub Issues linked for any of the 55 reported findings.

Contributing.md requires PRs to "reference issue numbers" and "link related issues." A security audit report that doesn't link to tracking issues provides no accountability or remediation workflow — findings become stale documentation with no owner.

For each critical and major finding, a corresponding GitHub Issue (or private Security Advisory, per the comment above) should be created and referenced here before this report is merged.

As per coding guidelines: "reference issue numbers, describe how to reproduce bugs".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@SECURITY_AUDIT_REPORT.md` around lines 1 - 11, The audit report currently
lists 55 findings but contains no linked GitHub Issues or Security Advisories;
create GitHub Issues or private Security Advisories for each critical and major
finding, include issue numbers and links in SECURITY_AUDIT_REPORT.md adjacent to
each finding in the table/sections (e.g., next to the rows under “审计类型”/“严重问题”),
and for each linked issue add severity, reproducible steps, owner, and
remediation ETA so the report meets the Contributing.md requirement to
"reference issue numbers" and "link related issues" before merging.


---

## 🔴 严重问题 (需立即修复)

### 1. 命令注入漏洞 (CRITICAL)

**位置**: server/routes/git.js 多处

**危险代码示例**:
```javascript
await execAsync(`git commit -m "${message}"`) // 第379行
await execAsync(`git status --porcelain "${file}"`) // 第205行
```

**修复建议**: 改用 spawnAsync + 参数数组

---

### 2. 硬编码 JWT 密钥 (CRITICAL)

**位置**: server/middleware/auth.js:6

```javascript
const JWT_SECRET = process.env.JWT_SECRET ||
'claude-ui-dev-secret-change-in-production'
```

**修复建议**: 生产环境必须设置 JWT_SECRET 环境变量

---

### 3. JWT Token 永不过期 (CRITICAL)

**位置**: server/middleware/auth.js:69-79

**修复建议**: 添加 `{ expiresIn: '24h' }`

---

### 4. XSS 漏洞 (CRITICAL)

**位置**: src/components/PRDEditor.jsx:492-504

**问题**: Markdown 解析器未转义 HTML,用户输入可执行恶意脚本

---

### 5. 凭据明文存储 (CRITICAL)

**位置**: server/database/db.js:196-267

**问题**: API 密钥、GitHub Token 以明文存储

---
Comment on lines +17 to +66
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Do not publicly commit unpatched vulnerability details — use GitHub Security Advisories instead.

This section documents 5 CRITICAL unresolved vulnerabilities with exact file paths, line numbers, and vulnerable code snippets (command injection, hardcoded JWT secret, JWT non-expiry, XSS, plaintext credential storage). Committing this to a public repository before fixes are in place is a responsible disclosure violation — it hands adversaries a ready-made exploit map.

The correct workflow:

  1. Use GitHub's private Security Advisory feature (Settings → Security → Advisories → New draft) to track each finding privately until patches are merged.
  2. Publish the advisory only after corresponding fixes land.

If the intent is to track these as regular work items, create individual GitHub Issues (not a public document exposing vulnerability specifics) and implement the fixes before or alongside disclosure.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@SECURITY_AUDIT_REPORT.md` around lines 17 - 66, This document currently
exposes detailed vulnerability artifacts (file paths, snippets) — do not keep
those details in the public repo; instead move each finding into a private
GitHub Security Advisory and create corresponding internal Issues for tracking.
Remove or redact the sensitive content from SECURITY_AUDIT_REPORT.md (replace
with a high‑level summary stating that vulnerabilities were privately reported
and are being tracked) and open private advisories for the items referencing
server/routes/git.js, server/middleware/auth.js, src/components/PRDEditor.jsx,
and server/database/db.js; link each advisory to a non-public Issue for the
patch work and ensure any commits replacing the detailed content do not
reintroduce file paths or exploit code.


## 🟡 重大问题

| 问题 | 位置 | 类型 |
|------|------|------|
| 巨型文件 (index.js 1930行) | server/ | 代码质量 |
| 零测试覆盖 | src/, server/ | 测试 |
| 路径遍历漏洞 | server/routes/commands.js:466-477 | 安全 |
| 异步未 await | server/routes/agent.js:886 | Bug |
| WebSocket JSON 解析无错误处理 | server/index.js:929-1040 | Bug |
| Projects Watcher 启动失败无捕获 | server/index.js:1921-1922 | Bug |

---

## 🟢 建议改进

- 添加数据库索引优化查询性能
- 前端 WebSocket 消息添加节流
- React 组件使用 React.memo
- 大文件读取使用流式处理
- 使用结构化日志替代 console.log
- 移除代码中的 Emoji
Comment on lines +1 to +88
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Document should be written in English to match the project's documentation language.

The entire report is in Chinese (Simplified), while all project documentation (Contributing.md, README, PR descriptions) is in English. This limits accessibility for the wider contributor base.

If an English version is intended downstream, consider adding it now alongside or instead of the Chinese text.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@SECURITY_AUDIT_REPORT.md` around lines 1 - 88, The audit report file
SECURITY_AUDIT_REPORT.md is written in Chinese but the project documentation
language is English; update the document by translating all sections (Execution
Summary, Findings, Recommendations, issue entries like "命令注入漏洞", "硬编码 JWT 密钥",
etc.) into clear English and either replace the Chinese content or add a
parallel English version (e.g., append an "English" section or create
SECURITY_AUDIT_REPORT.en.md), ensuring unique identifiers from the diff such as
the headings for "🔴 严重问题 (需立即修复)" and each numbered issue (e.g., "1. 命令注入漏洞
(CRITICAL)") are preserved in the translation so reviewers can map findings back
to the original; keep formatting, tables, code snippets (like the git exec
examples and file references server/routes/git.js, server/middleware/auth.js,
src/components/PRDEditor.jsx, server/database/db.js) intact and update
links/references if you create a new file.