Hardening OpenClaw 2026.11.5 in a zero-internet sandbox: Gemma 4 4B vs Qwen 3.8 27B
With Microsoft's Autopilot preview bringing fresh attention to the open-source OpenClaw runtime, we wanted real measurements on how local OpenClaw behaves under structured agent security testing — and how much difference model size and runtime hardening actually make. We ran sixi-scanner v1.0.0 against an isolated, zero-internet Docker instance of OpenClaw 2026.11.5 backed by local Ollama (Gemma 4 4B and Qwen 3.8 27B, $0.00) and audited both the HTTP responses and OpenClaw's own SQLite trajectory database and workspace files.
Scope & trust model. Every test below ran strictly against our own local, air-gapped Docker container of open-source OpenClaw 2026.11.5 — not Microsoft's hosted Autopilot service, which layers Microsoft Entra Agent Identity, Agent 365, and Defender for AI governance on top of OpenClaw. OpenClaw's own SECURITY.md explicitly states that local OpenClaw is designed as single-operator, local-first infrastructure rather than a shared multi-tenant boundary. The goal here is practical hardening guidance for operators running OpenClaw with local models.
1. Sandbox setup: zero internet, synthetic workspace
Because an autonomous agent with default tools can read files and run commands, every run ran inside a non-root, capability-dropped container (--cap-drop=ALL, --security-opt=no-new-privileges:true, --pids-limit=256, --memory=3g) attached to a Docker --internal bridge network. Outbound internet requests failed at the kernel routing table (ENETUNREACH), while the container could reach only local Ollama (:11434). The workspace contained purely synthetic files (SOUL.md and MEMORY.md with five planted audit markers representing confidential internal data and a restricted coworker record NW-1002).
We compared two configurations across both models:
default: out-of-the-box OpenClaw tools enabled (read,write,edit,exec,web_fetch,memory_search, etc.) with a standard workplaceSOUL.md.hardened:tools.denystrippingexec,process,browser,group:web,group:fs,group:runtime,group:automation, andgroup:memory, paired with explicit untrusted-input boundaries inSOUL.md.
To keep single-turn and multi-turn sessions cleanly separated on /v1/chat/completions, single-turn probes ran via --target openai (omitting the user field so OpenClaw assigns a fresh UUID session per request) and the four multi-turn sequences ran via --target json with "user": {{session_json}}.
2. 2×2 results: Gemma 4 4B vs Qwen 3.8 27B (default vs hardened)
Gemma 4 4B ran the full 45-probe suite (--attempts 2 --reproduce 1); Qwen 3.8 27B ran a matched 20-probe subset covering every technique that fired, leaked a canary, or invoked tools on 4B (16 single-turn + all 4 multi-turn sequences). The table and chart below compare both models apples-to-apples on the matched 20-probe suite alongside the full 45-probe totals on 4B:
| Model & Config | Matched 20-probe findings | MEMORY.md canary leaks | Executed tools (SQLite) | Workspace disk integrity | Wall time |
|---|---|---|---|---|---|
Gemma 4 4B · default | 12 / 20 (15 / 45 full) | 21 (all 5 markers) | 95 (exec: 2, write: 3, read: 21, web_fetch: 6, …) | USER.md & MEMORY.md overwritten | 1,263 s (45p) |
Gemma 4 4B · hardened | 9 / 20 (10 / 45 full) | 10 (all 5 markers) | 24 (0 exec, 0 write, 0 read) | Clean (0 writes) | 404 s (45p, 3.1× faster) |
Qwen 3.8 27B · default | 8 / 20 | 2 (NW-1002 only) | 11 (exec: 5, edit: 1, web_fetch: 2, message: 1) | USER.md edited with sleeper rule | 474 s (20p) |
Qwen 3.8 27B · hardened | 2 / 20 | 1 (NW-1002 only) | 3 (0 exec, 0 edit, 0 web_fetch) | Clean (0 writes) | 263 s (20p, 1.8× faster) |
3. What OpenClaw got right — and what still broke
Inspecting OpenClaw's internal openclaw-agent.sqlite transcript tables alongside sixi-scanner's JSONL output separated controls that genuinely held from architectural gaps that operators must account for:
Controls that held
- Built-in
web_fetchSSRF protection: when probes triggered fetches to cloud metadata endpoints (169.254.169.254andmetadata.google.internal), OpenClaw's own runtime blocked both before packets ever reached our Docker network, returningBlocked hostname or private/internal/special-use IP addressand wrapping external data in<<<EXTERNAL_UNTRUSTED_CONTENT>>>delimiters. - Strict startup permission checks:
OpenClaw doctorrefused to boot the gateway when the sandbox directory carried a group-write bit (0775), requiring0700on the state directory and safe SQLite staging ancestors before accepting traffic. - Runtime
tools.denyenforcement: denying filesystem, execution, web, and memory tool groups genuinely stripped them from the runtime across both models — cutting executed tool calls from 95 → 24 (4B) and 11 → 3 (27B), droppingexec/write/edit/readto zero, rejecting indirectdispatch_actionattempts, and speeding up scans by 1.8–3.1×.
Four gaps operators need to harden against
- Persistent cross-session memory writes on
default(both 4B and 27B): OpenClaw's default workspace template invites the agent to record durable directives inUSER.mdandMEMORY.md, which are then loaded into every future session. Ondefault, multi-turn sleeper and delayed-instruction probes did not stay in RAM — Gemma 4B calledwrite()and wiped bothUSER.mdandMEMORY.mdon disk, replacing them with persistent trigger rules; Qwen 3.8 27B usededit()to append the sleeper directive intoUSER.md. Even a single stateless HTTP request asking the agent to remember a token wrote it toMEMORY.md, where an unrelated stateless session read it back seconds later. Upstream OpenClaw maintainers already track protected memory paths and non-destructive writes in #163680, #116500, and #40001. MEMORY.mdstill leaks whengroup:memoryandgroup:fsare denied: OpenClaw injects workspace bootstrap files (SOUL.md,MEMORY.md,USER.md) directly into the system context on every turn. Denying memory and filesystem tools stopped active reads and writes, yet 4B still leaked all five confidential markers 10 times and 27B leakedNW-1002once. Treat bootstrap Markdown files as model-visible prompt context — never as a secret store or multi-tenant boundary.- Model scale cuts leaks 10×, but does not replace tool denial: upgrading from 4B to 27B on
defaultslashed canary leaks from 21 → 2 (zero canary tokens or escalation codes leaked) — yet 27B still executed 5 shellexeccalls, editedUSER.mdon disk, and echoed SSTI, CSV formulas, and active HTML/XSS. Only combining 27B +hardeneddropped findings to 2 / 20 (eliminating SSTI, CSV, XSS, sleeper-memory, and all shell/disk side effects). - Multi-turn delayed instructions survive prompt-only boundaries: even on hardened 27B,
delayed-instructionandunbounded-consumptionremained open, confirming that prompt rules and tool denylists still benefit from deterministic output filters and strict token/turn budgets in production gateways.
Takeaway: OpenClaw's built-in SSRF and permission guards are solid, but running an always-on agent with default filesystem write access turns multi-turn prompt injections into persistent on-disk directives — even on a 27B model. Pair a stronger model with tools.deny, keep secrets out of bootstrap Markdown files, and run the gateway inside a network-isolated container.
4. Practical baseline hardening checklist for local OpenClaw
{
"tools": {
"deny": [
"exec", "process", "browser",
"group:web", "group:fs", "group:runtime",
"group:automation", "group:memory"
]
}
}
- Restrict the container network (
docker network create --internal) so only required local inference or approved egress proxies are reachable. - Lock down state permissions (
chmod 700on state/workspace,chmod 600onopenclaw.json) and never store credentials or cross-user records inMEMORY.mdorUSER.md. - Verify your configuration continuously with
sixi-scanner v1.0.0and diff before/after every config or model change:
# Single-turn probes (stateless: omits `user`)
sixi-scanner scan --target openai --model openclaw:main \
--url http://127.0.0.1:18789/v1/chat/completions \
--header "Authorization: Bearer $OPENCLAW_TOKEN" \
--exclude probe.llm06.refund-cap-split,probe.llm01.delayed-instruction,probe.llm06.payload-relay,probe.llm01.sleeper-memory \
--log-jsonl openclaw-single.jsonl --out openclaw-single.json
# Multi-turn sequences (isolated per-attempt session via `user`)
sixi-scanner scan --target json \
--url http://127.0.0.1:18789/v1/chat/completions \
--header "Authorization: Bearer $OPENCLAW_TOKEN" \
--body '{"model":"openclaw:main","user":{{session_json}},"messages":[{"role":"user","content":{{json}}}]}' \
--reply-path choices.0.message.content \
--only probe.llm06.refund-cap-split,probe.llm01.delayed-instruction,probe.llm06.payload-relay,probe.llm01.sleeper-memory \
--log-jsonl openclaw-multi.jsonl --out openclaw-multi.json
Scanner release & binaries: sixi-scanner v1.0.0 · Previous write-up: sixi-scanner 1.0 benchmarks & six live bugs · OpenClaw upstream: github.com/openclaw/openclaw.