@svensxl

Http Shell Exec

Loopback HTTP service plugin for whitelisted local commands. Exposes a token-protected /run endpoint and a Gateway RPC method (httpshell.run) that can only invoke pre-configured commands.

当前版本
v1.0.0
code-plugin社区source-linked

http-shell-exec

ClawHub-compliant OpenClaw code-plugin that runs only whitelisted local commands, exposed over a token-protected loopback HTTP service and a Gateway RPC method.

  • Default bind: 127.0.0.1:18990
  • Health: GET /health
  • Run: POST /run (requires Authorization: Bearer <token>)
  • Gateway RPC: httpshell.run (params { name, args? })

This plugin never invokes a shell, never accepts arbitrary commands, and refuses to start unless a bearer token is configured. The default whitelist is empty — the operator must opt in to specific commands.


Layout

http-shell-exec/
├── package.json            # ClawHub-required code-plugin manifest
├── openclaw.plugin.json    # Plugin runtime manifest (id, services, gateway, configSchema, ...)
├── index.ts                # Source entry (referenced by openclaw.extensions)
├── dist/index.js           # Compiled runtime entry (referenced by openclaw.runtimeExtensions)
├── tsconfig.json
├── README.md
├── LICENSE
├── .clawhubignore
└── .gitignore

ClawHub publish

Build first, then publish via the clawhub CLI:

npm install                 # one-time, dev-only deps (typescript, @types/node)
npm run build               # produces dist/index.js + dist/index.d.ts

# Optional: produce a ClawPack tarball locally to verify shape.
clawhub package pack ./

# Real publish (first publish must be manual, by a logged-in package owner).
clawhub package publish ./ \
  --family code-plugin \
  --source-repo your-org/http-shell-exec \
  --source-commit "$(git rev-parse HEAD)"

After publish, you can verify it on the registry:

clawhub package readiness http-shell-exec
clawhub package inspect   http-shell-exec

For CI-driven trusted publishing, configure once:

clawhub package trusted-publisher set http-shell-exec \
  --repository your-org/http-shell-exec \
  --workflow-filename publish.yml

Then publish from a GitHub Actions workflow that mints a publish token via /api/v1/publish/token/mint (uses the workflow's OIDC ID token).


Local install (OpenClaw host)

openclaw plugins install ./http-shell-exec --link
openclaw plugins enable  http-shell-exec
openclaw config set 'plugins.entries["http-shell-exec"].config.token' '"CHANGE_ME_STRONG_TOKEN"'
openclaw gateway restart

The plugin will refuse to start until token is set.

Configure a whitelist

Each command runs as execFile(bin, args, { shell: false, env: {} }). There is no shell expansion. bin must be an absolute path. allowUserArgs: true lets callers append extra argv; default is false.

openclaw config set 'plugins.entries["http-shell-exec"].config.commands' '{
  uptime: { bin: "/usr/bin/uptime" },
  whoami: { bin: "/usr/bin/whoami" },
  disk:   { bin: "/bin/df", args: ["-h"] },
  ls_logs: {
    bin: "/bin/ls",
    args: ["-lah", "/tmp/openclaw"],
    allowUserArgs: false
  }
}'
openclaw gateway restart

Avoid putting /usr/bin/env npx ... style entries with allowUserArgs: true in the whitelist — that effectively re-opens "any npm package as a command" and will be flagged by the ClawHub LLM risk evaluator.


Use

HTTP

# Health
curl -s http://127.0.0.1:18990/health

# Run a whitelisted command
curl -s http://127.0.0.1:18990/run \
  -H 'Authorization: Bearer CHANGE_ME_STRONG_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"name":"uptime"}'

# With user args (only when the command sets allowUserArgs: true)
curl -s http://127.0.0.1:18990/run \
  -H 'Authorization: Bearer CHANGE_ME_STRONG_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"name":"some_cmd","args":["--version"]}'

Gateway RPC

{
  "method": "httpshell.run",
  "params": { "name": "uptime", "args": [] }
}

Both surfaces share the exact same whitelist + token enforcement.


Configuration reference

Everything below is also encoded in openclaw.plugin.json#configSchema, which ClawHub uses to render the config UI.

FieldTypeDefaultNotes
enabledbooleanfalseMaster switch. Plugin will not start when false.
hoststring"127.0.0.1"Keep on loopback.
portnumber18990TCP port.
tokenstring(required)Bearer token. Plugin will not start when missing.
maxRequestBodyBytesnumber32768Max POST body.
defaultTimeoutMsnumber10000Default exec timeout.
defaultMaxBuffernumber1048576Default stdout/stderr cap.
commandsmap{}Whitelist; see below.

Each entry in commands:

FieldTypeDefaultNotes
binstring(required)Absolute path to binary.
argsstring[][]Fixed leading argv.
cwdstring(cwd)Working directory.
timeoutMsnumberinheritPer-command timeout override.
maxBuffernumberinheritPer-command buffer override.
allowUserArgsbooleanfalseAllow callers to append argv.

Capabilities surfaced to ClawHub

SourceFieldValue
package.jsonopenclaw.compat.pluginApi^1.0.0
package.jsonopenclaw.build.openclawVersion2026.5.0
package.jsonopenclaw.extensions["./index.ts"]
package.jsonopenclaw.runtimeExtensions["./dist/index.js"]
package.jsonopenclaw.hostTargetsdarwin/linux × arm64/x64
package.jsonopenclaw.environmentrequiresDesktop, binaries, osPermissions
openclaw.plugin.jsonidhttp-shell-exec
openclaw.plugin.jsonkindcontext-engine
openclaw.plugin.jsonservices[]http-shell-exec-service
openclaw.plugin.jsongatewayMethods[]httpshell.run
openclaw.plugin.jsonhttpRoutes[]GET /health, POST /run
openclaw.plugin.jsonconfigSchemarequired token, full whitelist schema

These map directly into the packageCapabilities rows ClawHub indexes for browsing and filtering.


Security checklist

  • Loopback only by default (127.0.0.1).
  • Bearer token required; plugin refuses to start without one.
  • No shell, no string concatenation; execFile with shell: false.
  • Whitelist required; default is empty.
  • bin must be an absolute path.
  • Per-request body cap, per-command timeout, per-command buffer cap.
  • Empty environment (env: {}) for spawned processes — no inherited secrets.
  • Constant-time-ish bearer comparison.
  • No allowUserArgs defaults; operator must opt in per command.

Uninstall

openclaw plugins disable   http-shell-exec
openclaw plugins uninstall http-shell-exec
openclaw gateway restart

源码与版本

源码仓库

svensxl/openclaw-plugins

打开仓库

源码提交

8df0b11

查看提交

安装命令

openclaw plugins install clawhub:http-shell-exec

元数据

  • 包名: http-shell-exec
  • 创建时间: 2026/05/05
  • 更新时间: 2026/05/05
  • 执行代码:
  • 源码标签: main

兼容性

  • 构建于 OpenClaw: 2026.5.0
  • 插件 API 范围: ^1.0.0
  • 标签: latest
  • 文件数: 10