Skip to content

安全修复:Markdown / 文本对比 / 正则结果中的 DOM XSS 缓解 - #10

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-correctness-bugs-03a9
Draft

cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-correctness-bugs-03a9

Conversation

@cursor

@cursor cursor Bot commented May 16, 2026

Copy link
Copy Markdown

问题与影响

index.html 中,Markdown 预览文本对比正则匹配结果将用户输入直接拼进模板并赋给 innerHTML。攻击者可诱导用户粘贴恶意载荷(例如包含 <img onerror=...></span><script>... 的文本),在同一页面上下文中执行脚本,构成 DOM XSS,可能导致剪贴板窃取、钓鱼或会话相关风险(视页面其它能力而定)。

根因

未对用户可控文本做 HTML 转义即写入 innerHTML;Markdown 的正则替换还会把标题等捕获组原样插入 HTML。

修复

  • 新增 escapeHtml(),对 &'"<> 进行实体转义。
  • Markdown:先对全文 escapeHtml,再执行原有轻量级替换,使标题/加粗等捕获内容已为安全文本。
  • 文本对比正则结果(及正则错误信息):在插入模板前对动态片段使用 escapeHtml

验证

  • 本地执行:node --test tests/*.mjs(通过)。
  • 新增 tests/escape-html.test.mjs 锁定转义行为;新增 .github/workflows/ci.yml 在推送/PR 时运行上述测试。
Open in Web View Automation 

Escape user-controlled strings before assigning innerHTML, and
pre-escape Markdown source before lightweight pattern replacements.
Add Node tests and a CI workflow for escapeHtml parity checks.

Co-authored-by: Muki182 <Muki182@users.noreply.github.com>
@ecc-tools

ecc-tools Bot commented May 16, 2026

Copy link
Copy Markdown

Analyzing 200 commits...

@ecc-tools

ecc-tools Bot commented May 16, 2026

Copy link
Copy Markdown

Analysis Complete

Generated ECC bundle from 1 commits | Confidence: 50%

View Pull Request #11

Repository Profile
Attribute Value
Language TypeScript
Framework Not detected
Commit Convention freeform
Test Directory separate
Changed Files (3)
Metric Value
Files changed 3
Additions 56
Deletions 6

Top hotspots

Path Status +/-
tests/escape-html.test.mjs added +26 / -0
index.html modified +15 / -6
.github/workflows/ci.yml added +15 / -0

Top directories

Directory Files Total changes
tests 1 26
. 1 21
.github/workflows 1 15
Analysis Depth Readiness (commit-history, 21%)

ECC Tools uses this to decide whether recommendations should stay at commit-history/setup guidance or expand into CI, security, harness, reference-set, AI-routing, and team backlog work.

Area Status Evidence / Next Step
Commit history Partial 1 commits sampled
CI/CD signals Ready .github/workflows/ci.yml
Security evidence Missing Add AgentShield, audit, SARIF, SBOM, or security review evidence so recommendations can cover security posture.
Harness configuration Missing Add Claude, Codex, OpenCode, MCP, plugin, or cross-harness config evidence for harness-agnostic recommendations.
Reference/eval evidence Missing Add fixtures, golden traces, reference sets, or evaluator benchmarks so deeper recommendations have regression evidence.
AI routing and cost controls Missing Add model-routing, budget, usage, or cost-control files before relying on AI-heavy automation recommendations.
Team handoff and project tracking Missing Add roadmap, runbook, project, Linear, or follow-up tracking docs so generated work can land in a team queue.
Reference Set Readiness (0/6, 0%)
Area Status Evidence / Next Step
Deep analyzer corpus Missing Add analyzer fixture, golden, benchmark, or reference-set files that can catch analyzer regressions.
RAG/evaluator comparison Missing Add retrieval or evaluator reference-set comparison fixtures with expected ranking behavior.
PR salvage/review corpus Missing Add stale-PR, review-thread, reopen-flow, or salvage reference cases for queue cleanup automation.
Harness compatibility Missing Add cross-harness, adapter-compliance, or harness-audit evidence for Claude, Codex, OpenCode, and agent surfaces.
Security evidence Missing Attach security evidence such as SBOMs, SARIF, audit reports, or AgentShield evidence packs.
CI failure-mode evidence Missing Add captured CI failure logs, dry-run fixtures, or troubleshooting docs for common workflow failure modes.
Likely Future Issues (2)
Severity Signal Why it may show up
MEDIUM CI workflow changes may ship without failure-mode evidence 1 CI/test-runner paths changed; 0 CI failure-mode evidence artifacts changed
MEDIUM Dependency or CI drift could surface after merge CI/workflow files changed; no lockfile changes detected
  • CI workflow changes may ship without failure-mode evidence: The PR changes CI workflows or test-runner entrypoints without touching CI failure fixtures, captured logs, troubleshooting notes, or regression evidence.
  • Dependency or CI drift could surface after merge: Package or workflow changes landed without an accompanying lockfile update, which often turns into CI or release noise later.
Suggested Follow-up Work (2)
Type Suggested title Targets
PR ci: add failure-mode evidence for .github/workflows/ci.yml .github/workflows/ci.yml
PR chore: refresh lockfile and validate CI after dependency updates .github/workflows/ci.yml
  • ci: add failure-mode evidence for .github/workflows/ci.yml: Backfill CI failure-mode evidence before another workflow or test-runner change lands on the touched surface.
  • chore: refresh lockfile and validate CI after dependency updates: Package or workflow changes without a lockfile refresh tend to turn into noisy follow-up fixes after merge.

Copy-ready bodies

ci: add failure-mode evidence for .github/workflows/ci.yml

## Summary
- Add CI failure-mode evidence for the recently changed workflow or test-runner surface.

## Why
- Backfill CI failure-mode evidence before another workflow or test-runner change lands on the touched surface.

## Touched paths
- `.github/workflows/ci.yml`

## Validation
- Add or update a CI failure fixture, captured failing log, troubleshooting note, workflow dry-run evidence, or regression test for the changed CI/test-runner behavior.
- Run the affected workflow or test-runner entrypoint locally or in CI and record pass/fail evidence.

chore: refresh lockfile and validate CI after dependency updates

## Summary
- Refresh the lockfile and rerun CI after the dependency or workflow changes in this PR.

## Why
- Package or workflow changes without a lockfile refresh tend to turn into noisy follow-up fixes after merge.

## Touched paths
- `.github/workflows/ci.yml`

## Validation
- Refresh the lockfile in the same package manager used by the repo.
- Run the repo typecheck / test / CI entrypoints that depend on the updated package graph.
Generated Instincts (14)
Domain Count
git 3
code-style 8
testing 2
workflow 1

After merging, import with:

/instinct-import .claude/homunculus/instincts/inherited/toolrabbit-instincts.yaml

Files

  • .claude/ecc-tools.json
  • .claude/skills/toolrabbit/SKILL.md
  • .agents/skills/toolrabbit/SKILL.md
  • .agents/skills/toolrabbit/agents/openai.yaml
  • .claude/identity.json
  • .codex/config.toml
  • .codex/AGENTS.md
  • .codex/agents/explorer.toml
  • .codex/agents/reviewer.toml
  • .codex/agents/docs-researcher.toml
  • .claude/homunculus/instincts/inherited/toolrabbit-instincts.yaml

ECC Tools | Everything Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant