| 标题 | zhayujie chatgpt-on-wechat <= 2.0.7 OS Command Injection (CWE-78) |
|---|
| 描述 | # Technical Details
An Unauthenticated Remote Code Execution (RCE) via Agent Bash Tool Bypass exists in the `Bash` tool in `agent/tools/bash/bash.py` of chatgpt-on-wechat.
The application fails to sandbox OS commands and relies entirely on a trivial keyword blocklist (e.g., `rm -rf /`, `shutdown`). When the LLM decides to execute the `bash` tool based on a user's prompt, the input command is checked by the `_get_safety_warning` method which only checks for exact-match patterns. Commands that bypass the filter are passed without modification to a `subprocess.run(command, shell=True)` sink, running under the bot's privileges.
# Vulnerable Code
File: agent/tools/bash/bash.py
Method: _get_safety_warning / execute
Why: The `_get_safety_warning` method uses a trivial array-based exact blocklist, failing to effectively sanitize inputs. The `execute` method passes command input directly to `subprocess.run(shell=True)`.
# Reproduction
1. Deploy the `chatgpt-on-wechat` instance with default configurations (`use_agent: true`).
2. Download the HTTP Exploit script `exploit.py`.
3. Run `python3 exploit.py` to send crafted prompts to the `/message` endpoint, tricking the LLM into executing arbitrary code (e.g. `cat /etc/shadow`).
# Impact
- Complete Remote Code Execution on the system hosting the application.
- Complete host/container compromise, enabling lateral movement, data exfiltration, or hijacking of API keys. |
|---|
| 来源 | ⚠️ https://github.com/zhayujie/CowAgent/issues/2803 |
|---|
| 用户 | Eric-a (UID 96353) |
|---|
| 提交 | 2026-05-07 13時34分 (28 日前) |
|---|
| 管理 | 2026-05-31 09時19分 (24 days later) |
|---|
| 状态 | 已接受 |
|---|
| VulDB条目 | 367493 [zhayujie chatgpt-on-wechat 直到 2.0.8 Bash Tool agent/tools/bash/bash.py _get_safety_warning 权限提升] |
|---|
| 积分 | 20 |
|---|