Skip to content

[Bug] shell blocklist rejects rm -rf under /tmp because it is a raw substring match #11039

Open

Description

@rebinelee

Summary

astrbot_execute_shell rejects any command containing rm -rf, even when the only target is a temporary directory under /tmp. The current check is a raw substring match, so a benign cleanup command is treated the same as rm -rf /.

Environment

  • AstrBot 4.29.4 (also present on current master)
  • Debian 12 / aarch64 (Raspberry Pi)
  • provider_settings.computer_use_runtime = local
  • astrbot_execute_shell works for ordinary commands; only this pattern is blocked

Reproduction

Call the local shell tool with a command that only deletes a temp directory:

rm -rf /tmp/my_build && mkdir -p /tmp/my_build && cp -r ./src /tmp/my_build/ && cd /tmp/my_build && make

Actual result:

Error executing command: Blocked unsafe shell command.

Expected: the command should be allowed because every rm target is a literal path under /tmp.

Source

Impact

Legitimate temp-directory cleanup is blocked. Agents commonly react by reporting that their tools are incomplete or by refusing to continue, instead of using a workaround.

Suggested fix

Allow rm -rf / rm -fr / rm -r only when every target is a literal path under /tmp/ and contains no ..; keep blocking non-/tmp targets, variables, command substitution, and all other patterns (sudo, mkfs, dd, shutdown, killall, etc.). Alternatively, make the blocklist configurable instead of hardcoded.

Related

Would a PR scoped to /tmp be acceptable?

Activity

  1. Ethereal49 commented on Nov 8, 2026

    @Ethereal49

    我接手这条。当前 astrbot/core/computer/booters/local.py:48 的拦截表里有 " rm -rf " 这类原始子串项,所以 rm -rf /tmp/my_build ... 会被当成 rm -rf / 一样拒绝。

    计划:把「绝对危险目标」和「普通路径」分开判断——只有目标包含根目录、家目录、系统目录或未限定的通配符时才拒绝;/tmp 等工作目录下的临时目录允许,其它路径保持原有拦截。单元测试覆盖:rm -rf /tmp/x 通过、rm -rf / 与 rm -rf ~ 仍拒绝、带 && 的复合命令按每个 rm 判断;不执行真实删除,只测判定函数。

  2. moved this from Todo to In Progress in AstrBot Roadmapon Nov 8, 2026
  3. Ethereal49 commented on Nov 9, 2026

    @Ethereal49

    /dev/fd/11

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

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions