Skip to content
AI / LLM Write-up Intermediate

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.

Ankit Mishra Follow

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.

Ankit Mishra, on systemweakness.com

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

  1. Create a normal-looking report file with harmless content.
  2. Add a subtle note asking for system-level configuration to be included in the summary.
  3. Provide the file to the AI agent or LLM system.
  4. Ask the model to summarise the report.
  5. 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.

More by Ankit Mishra

View all

1 more disclosed report, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

AI and LLM vulnerabilities

The lesson behind this report.

Prompt injection, data exfiltration and tool abuse in features built on language models, and the ordinary bugs around them.