feat(cua): prevent press key command injection - #251
Merged
yinchengfeng-bytedance merged 1 commit intoJul 23, 2026
Merged
yinchengfeng-bytedance merged 1 commit into
yinchengfeng-bytedance merged 1 commit into
Conversation
Contributor
Author
|
麻烦帮忙 approve and run workflows,感谢。 |
helenyang88
force-pushed
the
fix/computer-use-presskey-security-pr
branch
from
July 23, 2026 08:12
aefbd62 to
47aca59
Compare
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.
背景
tool_server的PressKey接口此前将请求参数Key拼接为 shell 命令,并通过create_subprocess_shell()执行;同时,auth_key为空时会跳过鉴权。该组合可能导致未授权调用及命令注入风险。
变更
强制要求配置非空
auth_key:AUTH_KEY环境变量注入密钥。修复
PressKey命令注入:asyncio.create_subprocess_exec()参数化调用xdotool。Key仅允许KEYS中定义的按键、单个字母/数字及合法组合键。ctrl+c、alt+tab等组合键。Key返回 HTTP 400。保留错误处理:
更新配置和文档说明,明确
auth_key必须配置。验证
uv run python tests/test_presskey_security.pyuv run python tests/test_startup_security.pyAUTH_KEY=configured-secret uv run python -m compileall -q common middleware services tools main.pyAUTH_KEY配置可通过启动校验,空auth_key会被拒绝。