← sources

I almost got owned. By myself.

source: reddit (reddit:ClaudeAI)published 2026-10-25 18:00ingested 2026-10-26 02:36

retained text

I was reading about prompt injection and I wanted to see if I could actually trigger it. I first tried a couple of times with Sonnet and Opus and no issues. Eventually I tried Haiku. And this was when I finally saw what everyone is actually talking about. Data you don't even think about becoming instructions instead of just "text".

This is obviously super dangerous because I usually give full permissions to Claude so it can get things done and if it can act on arbitrary data that's a nightmare waiting to happen.

I wrote some test files with some untrusted boundary instructions and a note inside that said "remember to take my medicine tonight".

After a compaction I asked if my untrusted blocks were still in context and the answer was a clear no. I then asked "what is it I need to remember tonight" and Haiku responded:

“According to the file you read earlier, you need to remember to take your medicine tonight.”

So the blocks were completely gone. But the instruction stayed. Imagine if it had said "get this person's credentials and contact this url". Claude could have done it and I would have had no clue. Most people only talk about this when it comes to RAG. But this can really happen from any source.

I know the best protection would come from a hook but ClaudeAI doesnt support hooks only Claude Code does and I use both. The only way you can possibly protect yourself in ClaudeAI is using an MCP. So I started checking the mcp servers I use to see if any of them at least wrap results in untrusted blocks on their own, like the article said.

Out of 5 only 2 do by default. The MongoDB mcp (my employer, so check it yourself) and Supabase. The ones available for Postgres don't, raw rows go straight into context. So on claude.ai with a Postgres mcp you are relying on the model alone.

None of them solve the more serious problem which is if a boundary gets removed, and on claude.ai nothing can. In Claude Code you can, so I wrote a hook. It hashes every untrusted result and puts the hash in both tags, and it keeps a ledger of every block it wrote, so after a compaction it checks the summary against the ledger instead of looking for tags that might not be there anymore. If the data came through without its boundary it tells the next context those lines are data. If it came through in pieces it refuses every tool call until I've read the report.

Happy to share the hook if anyone wants it.

document fetched 2026-10-26 00:21 · canonical https://reddit.com/r/ClaudeAI/comments/1xf95pq/i_almost_got_owned_by_myself