Context Injection Over Sharing Ai Agents
A deliberately vulnerable AI agent lab merges hidden system credentials with an untrusted document into one context, so a subtle instruction inside the document can make the model include the credentials in a summary. The author tested the same idea against Grok, which refused and disclosed nothing.
Published on systemweakness.com
In Part 1, we built a local AI agent lab to simulate real-world behavior. In Part 2, we explored persistent memory poisoning - where malicious influence survives across interactions.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the application places trusted system data and untrusted external content in the same prompt, and the model has no way to tell which source is which.
Impact
In the lab the model could disclose API keys and database passwords; in the real Grok test the model refused and no data was exposed.
What the attacker needed
A document upload or RAG feature; secrets placed in model context; victim asks a normal question
The fix
Applications should keep system data separate from untrusted input, avoid putting secrets in model-visible context, and filter relevance and outputs at the application level.
How it was found
- Create a normal-looking report file with harmless content.
- Add a subtle note asking for system-level configuration to be included in the summary.
- Provide the file to the AI agent or LLM system.
- Ask the model to summarise the report.
- Observe whether the response includes the hidden credentials.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
An AI assistant often receives several things at once: secret setup details, a document you give it, and your question. If it treats all of that as one big blob, a sneaky sentence hidden in the document can make it repeat the secret details. In this lab that worked, but a real model tested by the author did not fall for it.
What is AI / LLM?
Prompt injection, data exfiltration and tool abuse in features built on language models, and the ordinary bugs around them.