Skip to content

fix: add security guardrails and cleanup lint warnings#96

Open
Misaka477 wants to merge 1 commit into
stepfun-ai:mainfrom
Misaka477:fix/security-shell-path-traversal-redos
Open

fix: add security guardrails and cleanup lint warnings#96
Misaka477 wants to merge 1 commit into
stepfun-ai:mainfrom
Misaka477:fix/security-shell-path-traversal-redos

Conversation

@Misaka477

@Misaka477 Misaka477 commented Jul 4, 2026

Copy link
Copy Markdown

Summary

Three defense-in-depth security improvements plus lint warning cleanup.

Changes

Security Guardrails

  1. Shell command blocklist: added validateShellCommand() that intercepts system-destructive patterns before they reach the shell.

  2. Workspace path boundary check: resolveWorkspacePath() now verifies that resolved paths stay within the workspace root.

  3. ReDoS protection: jsGrep() validates regex patterns for nested quantifiers before compiling.

Lint Cleanup

Verification

@github-actions github-actions Bot added area/core packages/core area/realtime packages/realtime + extensions/realtime-* area/extensions extensions/llm, extensions/mcp (non realtime-*) labels Jul 4, 2026
@ZouR-Ma

ZouR-Ma commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

先说认可的部分:#88/#89/#90 三个安全 issue 都是真问题,jsGrep 的 ReDoS 兜底和「先探测再编译」的写法也对。但这个 PR 需要的返工比较多,按优先级列出:

  1. (必须)rebase,并砍掉已被 #10 覆盖的文件。 你开 PR 之后 chore: fix lint warnings in VAD, AEC, and stateless adapter #10 已合入,把 VAD/AEC/stateless adapter 的 lint 警告清掉了——所以本 PR 现在是 CONFLICTING,cli-handlers.ts/resolver.ts/stepfun-stateless.ts/browser-audio-driver.ts 这些改动大概率已多余。rebase 后 lint 清理保留 factory.test.tsmocks.ts 两处即可(正是 main 当前仍有的警告),body 里「0 warnings」的说法也请同步改。
  2. (必须)shell 命令拦截改挂到既有的 policy/inspection 层,不要在 bashExecute 里硬拦。 仓库已经有一套命令安全架构:packages/core/src/policy/tool-policy.ts#2 建立)+ inspectToolCall 风险分级 + 网关审批流——危险命令的既定路径是「识别 → 提风险 → 人工确认」。在工具实现层加无条件硬拦截等于开了第二套互不知晓的策略层,而且硬 blocklist 双向都不牢:dd/chown 全禁会误伤合法操作,echo "别跑 rm -rf /" 这种提及危险命令的输入也被拦且用户无法 override;反过来 rm -rf /*bash -c '…'、变量拼接全都绕得过去。建议把这组 pattern 变成 inspection 层的风险信号:匹配则强制 confirm(任何审批模式下都弹),防御纵深还在、人在环上、单一事实来源。验收标准:bashExecute 无硬拦截 + 一条「危险 pattern 强制审批」用例。
  3. (必须)修 resolveWorkspacePath 检查自身的洞,并论证行为变更。 (a) startsWith(path.resolve(workspaceRoot)) 有经典前缀漏洞:workspace 是 /repo/repo-evil/x 能通过——请改成 normalized === root || normalized.startsWith(root + path.sep),Windows 注意大小写;(b) 绝对路径此前是放行的,改后一律拒绝 workspace 外,读 /tmp、全局配置这类合法场景会直接坏——这是行为变更不是纯加固,请在 body 里写清影响面,收紧与否我们拍板;(c) 同一函数在 file-tools.tsshell-tools.ts 复制了两份,请抽成共享辅助(你在 #98 里正在做同类去重)。
  4. (必须)撤销 .gitignore 改动。 AGENTS.md §7 明确暂不接收对它的修改;个人工作文件用本地 .git/info/exclude

ReDoS 防护可以保留,建议给「pattern skipped」的返回文案带上原 pattern 方便改写,并补两条启发式的边界用例。流程上:测试矩阵没跑是首次贡献者 workflow 需要我们批准,修完 push 后我们来点。三个 PR 之间有文件重叠,这个建议排在 #98/#97 之后进。改完 @ 我们。

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

Labels

area/core packages/core area/extensions extensions/llm, extensions/mcp (non realtime-*) area/realtime packages/realtime + extensions/realtime-*

Projects

None yet

2 participants