Skip to content

fix(cdp-proxy): block screenshot path traversal and header injection#112

Open
MaxQian888 wants to merge 1 commit into
eze-is:mainfrom
MaxQian888:fix/screenshot-path-traversal
Open

fix(cdp-proxy): block screenshot path traversal and header injection#112
MaxQian888 wants to merge 1 commit into
eze-is:mainfrom
MaxQian888:fix/screenshot-path-traversal

Conversation

@MaxQian888
Copy link
Copy Markdown

Summary

  • /screenshot?file= 加路径白名单(仅允许 os.tmpdir()process.cwd() 下),阻止任意路径写入(原实现 fs.writeFileSync(q.file, ...) 无校验,file=../../etc/passwd / C:\Windows\... 可越权写)
  • /screenshot?format= 改为 png/jpeg/webp 显式白名单,防 Content-Type: image/${format} 响应头注入
  • main() 检测已有实例时改用 JSON.parse(d).status === 'ok' 严格匹配(原 d.includes('"ok"') 子串过松,任何含 "ok" 字面量的 JSON 都会通过)
  • .claude-plugin/plugin.json 版本对齐 SKILL.md(2.4.22.5.0

/eval/setFiles 等"按设计就强大"的端点不动 —— 它们是 skill 核心能力,且 proxy 仅绑 127.0.0.1

Test plan

  • node --check scripts/cdp-proxy.mjs 语法通过
  • isSafeWritePath 8 个用例:tmpdir / cwd 子路径放行;/etc/passwdC:\Windows\...../../、空串、null 全部拒绝
  • node -e "require('./.claude-plugin/plugin.json').version" 输出 2.5.0
  • 手动:启动 proxy 后 curl ".../screenshot?target=ID&file=../../etc/passwd" 期望 400 + 错误说明
  • 手动:启动 proxy 后 curl ".../screenshot?target=ID&format=jpeg%0d%0aX:Y" 期望响应头无注入

🤖 Generated with Claude Code

- /screenshot?file= 限制写入路径到 os.tmpdir() 与 process.cwd() 下
- /screenshot?format= 改为 png/jpeg/webp 白名单,防 Content-Type 头注入
- main() 已有实例检测改用 JSON.parse 严格匹配 status === 'ok'
- .claude-plugin/plugin.json 版本对齐 SKILL.md (2.5.0)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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