Skip to content

[PR] fix: escape pck-banner session ids before innerHTML (#2645, found in #3781 release review) - #3808

Merged
ranxianglei merged 1 commit into
masterfrom
fix/pck-banner-escape-session-ids
Oct 19, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
fix/pck-banner-escape-session-ids

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

什么坏了

管理面板(web panel)新增的 pck 屏蔽横幅(#2645)把会话 id 原样拼进 innerHTML。会话 id 来自客户端自报的 header(x-session-id 等,只 trim 不过滤字符),所以一个能访问代理端口的客户端可以借一次 A/B 探测把 HTML 注入横幅;操作员打开面板时脚本以面板权限执行(面板可读写配置,含上游密钥)。默认绑回环时风险低;LAN/VPS 暴露部署时是真实攻击面。页面无 CSP 兜底。

根因

src/web/client.ts:876(本版本新代码):同一段里 model/origin 都过了 escapeHtml,唯独 p.sessions.join(", ") 裸拼——它经 t()(纯字符串替换,不是转义边界)直达 kb.innerHTML。输入端 src/session-id.ts 的 header 白名单只 trim,src/session.ts:1008 原样入库,GET /__bili/overview 原样发布。

修复

一行:t("pck.sessions", { ids: escapeHtml(p.sessions.join(", ")) })。

测试

新增 tests/issue2645-pck-banner-escape.test.ts(沿用 conflict-remediation 的 WEB_CLIENT 切片执行模式):

  • 探针 escapeHtml 断言 id 列表作为整体过了一遍 escapeHtml;
  • 用真实转义算法断言 <img onerror> payload 渲染为 &lt;img;
  • 静态钉死裸拼形式不得回归;
  • 空列表保持横幅隐藏。

验证:改前 2/3 失败(负控制),改后 3/3 通过;相邻 WEB_CLIENT 消费者测试(issue2861 / issue2462 / conflict-remediation / web-fmtw)全绿。

来源

#3781 发版整体审核(v0.1.201..pr-3781 全量 diff)中发现;诊断细节见审核报告。同类遗留:诊断 blob 的 config 段会原样输出内网中转地址(src/web/diagnostics.ts:213-226,与 #255 日志遮蔽纪律不一致),建议另行小 PR 处理。

@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: fix/pck-banner-escape-session-ids (37d2ae0)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.4504-pr.3808.831d974

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr3808.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei
ranxianglei merged commit 6b714a9 into master Oct 19, 2026
39 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.601-master.6b714a9 (rolling master tag).

npm install -g billion-context@0.0.601-master.6b714a9  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

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