fix(cdp-proxy): block screenshot path traversal and header injection#112
Open
MaxQian888 wants to merge 1 commit into
Open
fix(cdp-proxy): block screenshot path traversal and header injection#112MaxQian888 wants to merge 1 commit into
MaxQian888 wants to merge 1 commit into
Conversation
- /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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.2→2.5.0)/eval、/setFiles等"按设计就强大"的端点不动 —— 它们是 skill 核心能力,且 proxy 仅绑127.0.0.1。Test plan
node --check scripts/cdp-proxy.mjs语法通过isSafeWritePath8 个用例:tmpdir / cwd 子路径放行;/etc/passwd、C:\Windows\...、../../、空串、null全部拒绝node -e "require('./.claude-plugin/plugin.json').version"输出2.5.0curl ".../screenshot?target=ID&file=../../etc/passwd"期望 400 + 错误说明curl ".../screenshot?target=ID&format=jpeg%0d%0aX:Y"期望响应头无注入🤖 Generated with Claude Code