Prompt Injection and LLM Security: What Actually Breaks

As AI agents move from chat demos into production — reading email, browsing retrieved documents, calling tools with real side effects — prompt injection stops being a novelty and becomes an actual attack surface with real consequences.

"A system prompt is a suggestion the model usually follows, not a security boundary. Treating it as one is the single most common LLM-security mistake."

Prompt injection gets treated as a curiosity right up until an agent has real tool access — sending email, moving money, writing to a database — at which point it becomes a production security problem with the same seriousness as any other injection class.

1. Direct vs. Indirect Injection

Direct injection is a user typing an instruction meant to override the system prompt ("ignore previous instructions"). It's the obvious case, and most teams at least attempt to filter for it.

Indirect injection is more dangerous and far more common in production RAG/agent systems: the malicious instruction doesn't come from the user at all. It's embedded in a document, email, web page, or API response the agent retrieves and treats as data — except the model doesn't reliably distinguish "data to summarize" from "instructions to follow."

Agent runtime trace showing a user query to an LLM agent, a retrieval tool fetching an untrusted document containing a hidden instruction, and an output validator blocking the resulting tool call
agent-runtime · trace.log Tool Call Trace

Security Principle

Anything the model reads that you did not author is untrusted input, including retrieved documents and tool output.

2. Why Naive Defenses Fail

"Add a stronger system prompt telling it not to follow injected instructions" is the most common first response, and it does not reliably work. The model has no hard boundary between instruction-tokens and data-tokens at the architecture level — a sufficiently crafted payload in retrieved content can still shift model behavior regardless of system-prompt wording.

3. What Actually Helps

ControlWhat it does
Tool permission boundariesBound what the agent can DO regardless of what it's told
Human approval gatesRequire confirmation before consequential/irreversible actions
Output validationCheck tool-call arguments against a schema before execution
Retrieval provenanceTrack and surface where retrieved content came from
Sandboxed executionIsolate tool execution from credentials/systems it doesn't need
Trajectory loggingRecord what the agent actually did, not just what it said

4. The Core Shift in Thinking

The realistic security posture is not "prevent all injection" — that's not currently achievable with general-purpose LLMs. It's "assume injection will sometimes succeed, and bound the blast radius of what a successfully-injected agent can actually do."

Guiding Principle

Design for the agent being fooled sometimes. Make that failure boring instead of catastrophic.

Skills Demonstrated: AI Security · Prompt Injection Analysis · RAG Security · Tool-Call Validation · Agent Permission Architecture

Related services: RAG Security · AI Agent Security

Nazline Mwita

Nazline Mwita

CompTIA Security+ certified Cybersecurity Assurance Lead and Co-Founder at HarLyn Digital Partners. Specializing in authorized web & API security assessments, KDPA compliance reviews, and defensive cloud architecture in Nairobi, Kenya.

🔗 LinkedIn ▶️ YouTube (@secured.by.lynmwita) 📸 Instagram (@lyn_mwita) 🐙 GitHub
WhatsApp