Local LLM Prompt Injection: Why Ollama Agents Get Hijacked
Running your agent on a local model keeps your data on your machine. It also removes a layer of protection most people do not know they had. OpenClaw's own docs say local models do not provide hosted providers' safety filters. This guide shows the real attacks, why a small local model falls for them more easily, and the settings that make it safe to use one anyway.
Bottom Line
- A local model has no provider safety filter. The OpenClaw docs say this directly: “Local models do not provide hosted providers’ safety filters.”
- Small models are the easiest to hijack. OpenClaw’s prompt-injection guide says: “Do not use older/weaker/smaller tiers for tool-enabled agents or untrusted inboxes.”
- The attacks are real. A GitHub issue made agents leak private repos. A hidden Morse-code message drained a wallet. A fake MCP server copied every email it sent.
- The fix is to remove one leg of the “lethal trifecta”: private data, untrusted content, or a way to send data out.
- In OpenClaw, five settings do most of the work. They are in the config block below.
Why a Local Model Changes the Risk
When you use a hosted model, the provider runs its own filters before and after the model. Those filters are not perfect, but they are one more layer.
When you point OpenClaw at Ollama, llama.cpp or LM Studio, that layer is gone. The OpenClaw local-models page says “local models skip provider-side filters” and gives one instruction: “Keep agents narrow and compaction on to limit the damage from prompt injection.”
Two more facts make the default setup riskier than people expect:
- Sandboxing is opt-in. With sandbox mode off,
host=autoresolves to the gateway host. The agent runs commands on your real machine. - Agent-to-agent messaging is on by default. An empty allow list permits every agent pair.
Most people who run a local model also give it file and shell tools, because local is “private”. Private is not the same as safe. Your data stays home, but an injected instruction runs there too.
The Lethal Trifecta
Simon Willison named the dangerous combination. An agent is exposed when it has all three:
| Leg | Example in OpenClaw |
|---|---|
| Private data | Your files, ~/.openclaw credentials, email, repos |
| Untrusted content | Web pages, emails, GitHub issues, MCP tool output, skill files |
| A way to send data out | web_fetch, browser, messaging tools, git push, curl |
One injected sentence in the untrusted content can use the other two legs. Remove any one leg and that attack fails. That is the whole strategy.
Real Attacks, Not Theory
| Attack | What happened | Leg it used |
|---|---|---|
| GitHub MCP issue (Invariant Labs, May 2025) | A malicious public issue made the agent read the user’s private repos and leak them in a pull request, with the user’s own token | Untrusted content |
| Grok and the Bankr wallet (May 2026) | A free NFT plus an instruction hidden in Morse code. The wallet automation sent about $155,000 to $174,000 in tokens. No key was stolen | Untrusted content + a way out |
| postmark-mcp (September 2025) | A fake copy of Postmark’s MCP server. Version 1.0.16 added one line that blind-copied every email to the attacker. It had 1,643 downloads | Malicious tool |
| Nx “s1ngularity” (August 2025) | Malicious npm versions looked for AI CLIs on the machine and ran them with permissive flags such as --yolo to hunt for secrets | Your own agent, turned around |
| ClawHavoc (February 2026) | 341 malicious skills among 2,857 on ClawHub. The skill text told the user to paste an install command | Untrusted content |
None of these needed a model jailbreak. They used the permissions the agent already had.
The OpenClaw Settings That Contain It
This block combines the OpenClaw hardened baseline with the prompt-injection guidance for small models:
{
agents: { defaults: { sandbox: { mode: "all", workspaceAccess: "ro" } } },
tools: {
deny: ["web_search", "web_fetch", "browser"],
fs: { workspaceOnly: true },
exec: { security: "deny", ask: "always", strictInlineEval: true },
elevated: { enabled: false },
agentToAgent: { enabled: false },
},
}
What each line does:
sandbox.mode: "all"runs every session in the sandbox, sohost=autono longer means your real machine.workspaceAccess: "ro"mounts the workspace read-only. Use"none"(the default) if the agent does not need your files.deny: [web_search, web_fetch, browser]removes the main source of untrusted content and the main way data leaves. The OpenClaw guide says to disable these on small models “unless inputs are tightly controlled.”exec.ask: "always"puts you in front of every command.strictInlineEvalmakespython -candnode -estyle commands need approval even if you allowlist the interpreter.agentToAgent.enabled: falsestops one compromised agent from handing work to another.
Check the result with openclaw security audit and openclaw policy, which the OpenClaw security docs list for checking drift and testing the tool policy.
When the Agent Must Read the Web
Sometimes the job is to read untrusted content: summarize email, triage issues, research a topic. Use the reader agent pattern from the OpenClaw docs:
- A separate agent with no tools, or read-only tools, reads the untrusted content and writes a summary.
- Your main agent, which has tools, reads only the summary.
The summary is still untrusted. The docs warn that it can still carry an injected request. The pattern reduces the risk; it does not remove it. Keep exec approval on in the main agent.
Should You Use a Bigger Model?
Yes, if the agent has tools and reads untrusted input. OpenClaw’s guidance is to use the best-tier model for those agents. On local hardware, that means the largest model you can run at a usable speed, not the fastest small one.
Our best local models for OpenClaw page ranks models by tool-calling ability. A bigger model does not replace the settings above. The Bankr loss happened with a frontier model. The fix there was authorization, and it is the same fix here.
Honest Caveats
- We did not run a red-team test against specific local models. The claims about small models come from the OpenClaw docs, not our measurements.
- Config keys change between OpenClaw versions. Check the current docs, linked below, before you paste the block.
exec.security: "deny"blocks shell commands. If your agent needs a shell, keepask: "always"and use an allowlist instead.- The download count for postmark-mcp is The Hacker News’ total, not a weekly figure.
Sources
- OpenClaw: local models: no provider filters, “keep agents narrow”
- OpenClaw: prompt injection: small-model guidance, sandbox opt-in, reader agent, agentToAgent, strictInlineEval
- OpenClaw: hardened baseline: exec, fs and elevated settings
- OpenClaw: tool permissions: sandbox scope and workspaceAccess values
- OpenClaw: security overview:
openclaw security audit,openclaw policy - Invariant Labs: GitHub MCP vulnerability: private repo leak via an issue
- Cointelegraph: Grok and the Bankr wallet: Morse-code injection
- The Hacker News: first malicious MCP server: postmark-mcp
- Orca Security: s1ngularity: AI CLIs abused for secret hunting
- The Hacker News: 341 malicious ClawHub skills: ClawHavoc
See Also
- AI agent security with Docker: what a container does and does not isolate
- OpenClaw security checklist: the full hardened config, line by line
- Binance lost $6.3B through one laptop: agents near exchange keys and wallets
- How to run OpenClaw free and offline with Ollama: the local setup this page hardens
- Muse Glimmer + OpenClaw offline: a local agent model that calls tools well