← All guides

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=auto resolves 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:

LegExample in OpenClaw
Private dataYour files, ~/.openclaw credentials, email, repos
Untrusted contentWeb pages, emails, GitHub issues, MCP tool output, skill files
A way to send data outweb_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

AttackWhat happenedLeg 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 tokenUntrusted 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 stolenUntrusted 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 downloadsMalicious 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 secretsYour 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 commandUntrusted 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:

  1. sandbox.mode: "all" runs every session in the sandbox, so host=auto no longer means your real machine.
  2. workspaceAccess: "ro" mounts the workspace read-only. Use "none" (the default) if the agent does not need your files.
  3. 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.”
  4. exec.ask: "always" puts you in front of every command. strictInlineEval makes python -c and node -e style commands need approval even if you allowlist the interpreter.
  5. agentToAgent.enabled: false stops 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:

  1. A separate agent with no tools, or read-only tools, reads the untrusted content and writes a summary.
  2. 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

  1. 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.
  2. Config keys change between OpenClaw versions. Check the current docs, linked below, before you paste the block.
  3. exec.security: "deny" blocks shell commands. If your agent needs a shell, keep ask: "always" and use an allowlist instead.
  4. The download count for postmark-mcp is The Hacker News’ total, not a weekly figure.

Sources

See Also

Read next

Binance Lost $6.3B Through One Laptop. Is Your Agent on One?
Attackers took about $6.3 billion from Binance on 29 October 2026, starting from one engineer's laptop. What that means if your OpenClaw agent runs on a machine with exchange keys or a wallet, and the settings that limit the damage.
Context Rot Explained: Why Agents Get Worse Over Time
Context rot is the drop in model accuracy as the input grows, long before the context window is full. The benchmark data, why a 1M window is not 1M useful tokens, what compaction loses, and the fixes in Claude Code, the Claude API and OpenClaw.
Tool Search Explained: Why 100 Tools Make Agents Worse
Every tool you give an agent costs context and makes the right tool harder to pick. How tool search works (regex, BM25, embeddings), what it does to prompt caching, when code mode is better, and how to set it up in the Claude API, OpenAI and OpenClaw.
The AI Agent Security Guide Nobody Made: Docker Sandboxing, Secrets, and Prompt Injection (2026)
Is OpenClaw safe? A practical, defensive hardening guide for running OpenClaw or Hermes on your own machine: what Docker actually isolates, how to handle API keys, and how to survive prompt injection from web content.