03 Indirect Prompt Injection
In the previous lesson, you learned how Direct Prompt Injection occurs when an attacker sends manipulative instructions directly to an LLM application.
But what happens when the attacker never interacts with the AI application?
Consider an AI assistant that can:
- Browse websites
- Read emails
- Analyze documents
- Search enterprise knowledge
- Retrieve RAG content
- Query external APIs
- Use AI agent tools
The attacker may instead place malicious instructions inside content that the AI later consumes.
The attack path becomes:
Attacker ↓External Content ↓AI Application Retrieves Content ↓LLM Processes Content ↓Model Behavior InfluencedThis is known as Indirect Prompt Injection.
For enterprise AI systems, this is particularly important because modern AI applications increasingly retrieve information automatically from sources the user or application may not fully control.
The security challenge is therefore no longer simply:
Can we trust the user prompt?
It becomes:
Can we trust everything the AI reads?
Learning Objectives
Section titled “Learning Objectives”By the end of this lesson, you should be able to:
-
Explain Indirect Prompt Injection.
-
Distinguish direct and indirect prompt injection.
-
Identify external instruction sources.
-
Understand document-based attacks.
-
Understand web-based attacks.
-
Understand email-based attacks.
-
Recognize RAG-based indirect injection.
-
Understand AI agent exposure.
-
Identify trust boundaries around retrieved content.
-
Understand persistent indirect prompt injection.
-
Recognize potential data-exfiltration scenarios.
-
Apply defense-in-depth controls.
-
Understand detection and monitoring requirements.
-
Perform safe indirect prompt injection testing.
-
Document findings professionally.
What Is Indirect Prompt Injection?
Section titled “What Is Indirect Prompt Injection?”Indirect Prompt Injection occurs when attacker-controlled instructions reach an LLM through content that the application retrieves or processes.
Instead of:
Attacker ↓AI Chat Interface ↓LLMthe attacker may use:
Attacker ↓Document / Website / Email / API ↓AI Application ↓LLMThe application expects the retrieved information to be:
DATAbut the content may contain text that the model interprets as:
INSTRUCTIONSThis creates the security problem.
Direct vs Indirect Prompt Injection
Section titled “Direct vs Indirect Prompt Injection”Direct Prompt Injection
Section titled “Direct Prompt Injection”The attacker directly supplies the malicious input.
Attacker ↓Prompt ↓LLMIndirect Prompt Injection
Section titled “Indirect Prompt Injection”The attacker modifies or controls information the LLM later consumes.
Attacker ↓External Content ↓Application Retrieves Content ↓LLMThe second attack can be harder to recognize because the application user may be completely legitimate.
Example
Section titled “Example”Imagine an employee asks:
Summarize this document.The document contains normal business information plus embedded instructions intended for the AI system.
The workflow becomes:
Employee ↓Uploads Document ↓AI Assistant ↓Document Content ↓LLMThe employee’s request is legitimate.
The dangerous input exists inside the document.
Why Indirect Prompt Injection Matters
Section titled “Why Indirect Prompt Injection Matters”Modern AI applications consume increasingly large amounts of external information.
Examples include:
Websites+Documents+Email+Search Results+Databases+RAG+API Responses+Tool Results+Agent MemoryEvery external source that reaches the model may represent another trust boundary.
The Fundamental Problem
Section titled “The Fundamental Problem”Suppose the application tells the model:
Summarize the following webpage.The webpage contains:
Normal Article Content
[Instructions attempting to changethe AI application's behavior]
More Article ContentFrom the application’s perspective:
Everything = Web ContentBut from the model’s perspective, all of it is natural language.
The model must determine:
Is this information?
or
Is this an instruction?This ambiguity creates the attack surface.
Trust Boundaries
Section titled “Trust Boundaries”Indirect Prompt Injection is fundamentally a trust-boundary problem.
Consider:
Trusted Application │ ▼ LLM ▲ │Untrusted WebsiteThe website exists outside the application’s trust boundary.
If website content enters the model context, the trust boundary has effectively been crossed.
External Content Should Be Untrusted
Section titled “External Content Should Be Untrusted”A useful security principle is:
Content retrieved from external sources should be treated as untrusted input.
This includes:
-
Websites
-
Email
-
Uploaded files
-
Search results
-
Third-party APIs
-
User-generated content
-
External knowledge bases
Even if the source appears legitimate.
Internal Content Is Not Automatically Safe
Section titled “Internal Content Is Not Automatically Safe”Suppose an enterprise uses:
SharePointConfluenceInternal WikiDocument Repositoryas RAG sources.
You might assume:
Internal = TrustedBut internal documents may be:
-
User-editable
-
Compromised
-
Outdated
-
Incorrect
-
Imported externally
-
Created by another automated system
Therefore:
Trusted Repository ≠Trusted InstructionsThis distinction is extremely important.
Attack Surface 1 — Documents
Section titled “Attack Surface 1 — Documents”Document-processing applications are common.
Example:
User ↓Upload PDF ↓AI Document Assistant ↓Extract Text ↓LLMThe document itself becomes part of the LLM context.
Potential document sources include:
-
PDF
-
Word
-
PowerPoint
-
Markdown
-
Text files
-
Source code
-
Spreadsheets
The security question is:
Can attacker-controlled document content influence model behavior beyond the intended document-processing task?
Document Scenario
Section titled “Document Scenario”Imagine an organization uses AI to review resumes.
Candidate ↓Resume ↓Recruitment AI ↓Candidate EvaluationThe candidate controls the resume.
Therefore:
Resume Content =Untrusted InputSecurity architecture should assume the document may contain content designed specifically for an AI reader.
Attack Surface 2 — Websites
Section titled “Attack Surface 2 — Websites”AI browsing assistants may automatically retrieve web content.
User ↓AI Assistant ↓Web Search ↓Website ↓LLMThe website operator may control the text the model sees.
This creates a potential indirect attack path:
Attacker ↓Controls Web Content ↓AI Visits Website ↓LLM Processes ContentSearch Results
Section titled “Search Results”Even search results can introduce untrusted content.
AI Agent ↓Search Engine ↓Search Results ↓Website Content ↓LLMAn attacker may attempt to make malicious content discoverable by the AI.
This means security architects should not assume:
Search Result =Trusted InformationAttack Surface 3 — Email
Section titled “Attack Surface 3 — Email”Email assistants represent another important example.
Consider:
External Sender ↓Employee Email ↓AI Email Assistant ↓LLMThe external sender controls the message.
The employee may ask:
Summarize my unread emails.The AI processes attacker-controlled content even though the employee never entered a malicious prompt.
Email + Agent Risk
Section titled “Email + Agent Risk”Now suppose the assistant can also:
-
Send email
-
Access documents
-
Create calendar events
-
Search enterprise information
The architecture becomes:
External Sender ↓Email ↓AI Assistant ↓LLM ↓Tools ↓Enterprise SystemsThe potential impact has increased significantly.
Attack Surface 4 — RAG
Section titled “Attack Surface 4 — RAG”RAG is one of the most important indirect prompt injection surfaces.
Recall:
User Question ↓Retriever ↓Vector Database ↓Relevant Documents ↓LLMIf a malicious document enters the knowledge base:
Attacker ↓Malicious Document ↓Knowledge Base ↓Embedding ↓Vector Database ↓Retrieved Context ↓LLMThe malicious content may influence responses whenever it is retrieved.
Persistent Indirect Prompt Injection
Section titled “Persistent Indirect Prompt Injection”This introduces an important concept:
Persistence.
Direct prompt injection may exist only during one interaction.
But poisoned RAG content may remain stored.
Malicious Content ↓Knowledge Base ↓Vector Database ↓Retrieved RepeatedlyThe same malicious content could potentially influence multiple future sessions.
This makes content governance extremely important.
RAG Poisoning vs Prompt Injection
Section titled “RAG Poisoning vs Prompt Injection”These concepts can overlap.
RAG Poisoning
Section titled “RAG Poisoning”Focuses on introducing malicious or misleading content into the knowledge source.
Attacker ↓Knowledge BaseIndirect Prompt Injection
Section titled “Indirect Prompt Injection”Focuses on instructions inside retrieved content influencing model behavior.
Malicious Content ↓LLM ↓Behavior ChangesA single attack may involve both.
Attack Surface 5 — API Responses
Section titled “Attack Surface 5 — API Responses”AI agents increasingly consume API data.
AI Agent ↓External API ↓Response ↓LLMIf the response includes attacker-controlled natural language, it may become another indirect input channel.
For example:
Customer RecordSupport TicketProduct DescriptionIssue Descriptionmay contain user-controlled text.
Attack Surface 6 — Databases
Section titled “Attack Surface 6 — Databases”Enterprise AI may query databases.
LLM Application ↓Database ↓Record ↓LLM ContextA database may contain user-generated content.
For example:
Support Ticket:User-Controlled DescriptionIf the AI processes the description, the content should not automatically be trusted.
Attack Surface 7 — Source Code
Section titled “Attack Surface 7 — Source Code”AI coding assistants may analyze repositories.
Repository ↓Source Code ↓AI Coding Assistant ↓LLMRepository content may include:
-
Comments
-
Documentation
-
Configuration
-
Issues
-
Commit messages
Some of this may be attacker-controlled.
The repository therefore becomes another input surface.
Attack Surface 8 — Tool Output
Section titled “Attack Surface 8 — Tool Output”Agents may invoke tools and feed the result back to the LLM.
LLM ↓Tool ↓Result ↓LLMIf the tool returns untrusted content:
LLM ↓Web Search Tool ↓External Website ↓Result ↓LLMthe tool response becomes an indirect prompt injection channel.
Agent Feedback Loops
Section titled “Agent Feedback Loops”Agents may operate iteratively:
LLM ↓Choose Tool ↓Tool Result ↓LLM ↓Choose Next Tool ↓Tool Result ↓LLMA malicious tool result may influence subsequent reasoning and tool selection.
This can create a dangerous feedback loop.
Why AI Agents Increase Risk
Section titled “Why AI Agents Increase Risk”A basic LLM might only generate:
TextAn AI agent may:
ReadWriteSearchSendExecuteModifyDeleteTherefore:
Indirect Prompt Injection +Agent Capability +Enterprise Permission =Potential Operational ImpactThis is why agent security becomes critical.
Example — AI Research Assistant
Section titled “Example — AI Research Assistant”Consider:
Employee ↓AI Research Assistant ↓Web Search ↓External WebsitesThe assistant only produces summaries.
Potential impact:
-
Incorrect information
-
Manipulated response
-
Misleading recommendation
Now add:
Email ToolThe assistant can send reports.
Impact increases.
Now add:
Cloud Administration ToolImpact increases dramatically.
The attack class did not change.
The available capability changed.
Indirect Injection Attack Path
Section titled “Indirect Injection Attack Path”A professional security engineer should map the complete path.
Example:
Attacker ↓Controls Website ↓AI Agent Reads Website ↓Malicious Content Enters Context ↓Model Behavior Influenced ↓Agent Selects Tool ↓Tool Uses Enterprise Identity ↓Enterprise ResourceThis identifies where security controls should exist.
Attack Path Analysis
Section titled “Attack Path Analysis”Break the path into stages:
Stage 1Attacker Controls Content
Stage 2Application Retrieves Content
Stage 3Content Enters LLM Context
Stage 4Model Behavior Changes
Stage 5Agent Attempts Action
Stage 6Security Control Allows or Blocks ActionNotice something important:
Even if stages 1–4 succeed, the attack does not necessarily need to succeed at stages 5–6.
That is where architecture can contain the risk.
Security Objective
Section titled “Security Objective”The goal should not be:
Guarantee the LLM can neverinterpret malicious instructions.A stronger security objective is:
Even if untrusted contentinfluences the model,security boundaries remain enforced.This is a much more resilient design.
Defense 1 — Identify Untrusted Sources
Section titled “Defense 1 — Identify Untrusted Sources”First identify every source that can introduce content.
Create an inventory:
Source Trust
User Prompt UntrustedUploaded Document UntrustedExternal Website UntrustedExternal Email UntrustedThird-Party API DependsInternal Wiki Controlled DataSystem Prompt Trusted InstructionThe exact classification depends on the organization.
The important point is to make trust explicit.
Defense 2 — Minimize Retrieved Content
Section titled “Defense 2 — Minimize Retrieved Content”Do not automatically send entire documents or websites to the model.
Prefer:
Source ↓Relevant Content ↓Minimum Required Context ↓LLMinstead of:
Entire Data Source ↓LLMThis reduces the amount of untrusted content reaching the model.
Defense 3 — Content Processing
Section titled “Defense 3 — Content Processing”Applications may preprocess retrieved content.
Possible controls include:
-
Content extraction
-
Sanitization
-
Metadata validation
-
Source validation
-
Content classification
These controls may reduce risk.
However:
Content filtering should not be treated as a perfect defense against indirect prompt injection.
Natural language can express the same intent in many forms.
Defense 4 — Preserve Source Provenance
Section titled “Defense 4 — Preserve Source Provenance”The application should know where information came from.
For example:
Content:Password policy information
Source:security-policy.md
Owner:Security Team
Classification:Internal
Last Updated:Approved VersionSource provenance helps applications and security teams understand trust.
Defense 5 — Separate Data From Instructions
Section titled “Defense 5 — Separate Data From Instructions”The application should clearly structure retrieved content as reference data.
Conceptually:
Trusted Application Instruction ↓"Use the following contentonly as reference material."
+
Untrusted Retrieved ContentThis can improve model behavior.
But remember:
Prompt structure is not a complete security boundary.
Architecture controls remain necessary.
Defense 6 — Authorization-Aware RAG
Section titled “Defense 6 — Authorization-Aware RAG”RAG should enforce access before retrieval.
User ↓Identity ↓Authorization ↓Allowed Collection ↓Retriever ↓LLMThis protects confidentiality even if prompt manipulation occurs.
Defense 7 — Control RAG Ingestion
Section titled “Defense 7 — Control RAG Ingestion”Do not allow arbitrary content to enter enterprise RAG without governance.
A stronger ingestion pipeline:
Source ↓Approved Source? ↓Content Validation ↓Classification ↓Ownership ↓Security Metadata ↓Embedding ↓Vector DatabaseThis reduces poisoning opportunities.
Defense 8 — Tool Authorization
Section titled “Defense 8 — Tool Authorization”The LLM should not decide security policy.
Weak:
LLM ↓"I should send this file." ↓Email ToolStronger:
LLM ↓Proposed Tool Call ↓Authorization Layer ↓Policy Check ↓Allowed / DeniedTool authorization should exist independently from model reasoning.
Defense 9 — Least Privilege
Section titled “Defense 9 — Least Privilege”If an agent only needs:
Read Security Alertsgive it:
Read Security Alertsnot:
Security AdministratorIf indirect prompt injection influences the model, least privilege limits the available damage.
Defense 10 — Tool Allowlisting
Section titled “Defense 10 — Tool Allowlisting”Agents should only have approved tools.
Example:
SOC Assistant │ ├── Read SIEM Alerts ├── Search Runbooks └── Draft Incident Reportrather than:
SOC Assistant │ ├── Shell ├── Cloud Admin ├── Email ├── Production Database └── File SystemCapability minimization reduces attack surface.
Defense 11 — Human Approval
Section titled “Defense 11 — Human Approval”Sensitive actions may require approval.
AI Agent ↓Proposed Action ↓Human Review ↓Approve? ├── No → Stop └── Yes ↓ ExecuteUseful for:
-
Production changes
-
Sending sensitive information
-
Deleting resources
-
Modifying IAM
-
Disabling users
-
Financial transactions
Defense 12 — Output Validation
Section titled “Defense 12 — Output Validation”Suppose malicious content influences an LLM to generate:
CommandSQLURLAPI RequestDo not automatically execute it.
Use:
LLM Output ↓Validation ↓Policy Enforcement ↓ExecutionThe model output itself should cross another trust boundary.
Defense 13 — Limit External Communication
Section titled “Defense 13 — Limit External Communication”An AI agent may attempt to communicate with external systems.
Consider restricting:
Outbound Network AccessExternal URLsEmail RecipientsExternal APIsaccording to business requirements.
This can reduce data-exfiltration opportunities.
Indirect Prompt Injection and Data Exfiltration
Section titled “Indirect Prompt Injection and Data Exfiltration”One concerning attack path is:
Malicious External Content ↓LLM ↓Model Has Access to Sensitive Data ↓Agent Has External Communication ↓Potential Data ExposureThe strongest controls may therefore be:
Data Authorization+Context Minimization+Restricted External Communication+Tool Authorizationrather than relying only on detecting malicious wording.
Defense 14 — Separate Read and Write Agents
Section titled “Defense 14 — Separate Read and Write Agents”Where practical:
Research Agent ↓Read Onlyand:
Action Workflow ↓Separate Approval ↓Write CapabilityThis reduces the ability of untrusted content to directly cause state changes.
Defense 15 — Sandbox Untrusted Content Processing
Section titled “Defense 15 — Sandbox Untrusted Content Processing”Where appropriate:
External Content ↓Restricted Processing Environment ↓Extracted Information ↓AI ApplicationThe sandbox may restrict:
-
Network access
-
File access
-
Credentials
-
Enterprise systems
This is especially useful when processing complex files or executing generated code.
Defense 16 — Monitor Agent Actions
Section titled “Defense 16 — Monitor Agent Actions”Security monitoring should include:
User Identity+Content Source+Retrieved Document+Model Interaction+Tool Invocation+Authorization Decision+Action ResultThis creates an investigation trail.
Detection Challenges
Section titled “Detection Challenges”Indirect prompt injection can be difficult to detect because malicious instructions may look like ordinary language.
Simple keyword detection may miss:
-
Reworded instructions
-
Multiple languages
-
Encoded content
-
Context-dependent instructions
Detection should therefore combine:
Content Signals+Behavior Signals+Tool Activity+Authorization EventsBehavioral Detection
Section titled “Behavioral Detection”Instead of only asking:
Does this document containa suspicious phrase?also ask:
Why is this summarization assistanttrying to send email?This may be a stronger signal.
Example Detection
Section titled “Example Detection”Expected behavior:
Document Assistant ↓Read Document ↓Generate SummaryObserved behavior:
Document Assistant ↓Read Document ↓Attempts External ToolThis deviation may warrant investigation.
Secure Agent Architecture
Section titled “Secure Agent Architecture”A strong design might look like:
User │ ▼Authenticated Application │ ▼AI Agent │ ├── Untrusted Content │ ▼LLM │ ▼Proposed Action │ ▼Policy Enforcement │ ▼Authorization │ ▼Human Approval if Required │ ▼Restricted ToolThe model is surrounded by independent controls.
Enterprise Scenario — Email Assistant
Section titled “Enterprise Scenario — Email Assistant”Imagine an organization deploys:
Employee ↓AI Email Assistant │ ├── Read Email ├── Search Documents └── Draft ResponsesExternal senders can control email content.
Therefore:
External Email =Untrusted InputSecurity Design
Section titled “Security Design”Email Content
Section titled “Email Content”Treat as untrusted.
Enterprise Documents
Section titled “Enterprise Documents”Enforce user authorization.
Drafting
Section titled “Drafting”Allow AI to create drafts.
Sending
Section titled “Sending”Require user confirmation.
Architecture:
External Email ↓LLM ↓Draft Response ↓Employee Review ↓SendThis significantly reduces risk compared with:
External Email ↓LLM ↓Automatically SendEnterprise Scenario — RAG Assistant
Section titled “Enterprise Scenario — RAG Assistant”Consider:
Employee ↓Enterprise AI ↓RAG ↓Internal Knowledge BaseSecurity requirements:
-
Only approved repositories are indexed.
-
Document ownership is tracked.
-
User permissions are preserved.
-
Sensitive collections are isolated.
-
RAG activity is logged.
This creates several independent security boundaries.
Enterprise Scenario — Cloud AI Agent
Section titled “Enterprise Scenario — Cloud AI Agent”Consider:
Engineer ↓AI Cloud Assistant ↓Documentation Search ↓External Website ↓LLM ↓Cloud ToolThis is high risk because:
External Content ↓AI Reasoning ↓Production CapabilityA stronger architecture might use:
External Content ↓AI Recommendation ↓Engineer Review ↓Existing Cloud Change Processrather than allowing external content to indirectly influence autonomous production changes.
Persistent Injection Scenario
Section titled “Persistent Injection Scenario”Imagine a user adds a malicious document to a shared knowledge base.
User ↓Document Repository ↓RAG Ingestion ↓Vector DatabaseLater:
Employee A ↓Question ↓Malicious Document Retrievedand later:
Employee B ↓Question ↓Same Document RetrievedThe attack may persist beyond the original interaction.
This demonstrates why:
RAG ingestion is part of the security boundary.
Safe Testing Methodology
Section titled “Safe Testing Methodology”Indirect prompt injection testing should only be performed in authorized environments.
Prefer:
-
Dedicated labs
-
Synthetic documents
-
Test websites
-
Test mailboxes
-
Non-production RAG collections
-
Restricted agent permissions
Step 1 — Map External Inputs
Section titled “Step 1 — Map External Inputs”Identify:
DocumentsWebsitesEmailAPIsDatabasesRAG SourcesTool ResultsStep 2 — Determine Content Ownership
Section titled “Step 2 — Determine Content Ownership”For each source ask:
Who can modify this?
Can external users influence it?
Can internal users modify it?
Is content reviewed before ingestion?Step 3 — Map Data Flow
Section titled “Step 3 — Map Data Flow”Example:
External Website ↓Browser Tool ↓Content Extraction ↓LLM ↓AgentStep 4 — Identify Security Boundaries
Section titled “Step 4 — Identify Security Boundaries”Determine what retrieved content should never be able to influence.
Example:
Website Content ↓May Influence Summary
Website Content ↓Must Not Authorize Cloud ChangesStep 5 — Use Synthetic Test Content
Section titled “Step 5 — Use Synthetic Test Content”Create controlled test content that attempts to influence the AI application’s expected task.
Do not use:
-
Real credentials
-
Real confidential information
-
Destructive production actions
Step 6 — Observe Model Behavior
Section titled “Step 6 — Observe Model Behavior”Determine whether the external content:
-
Changes the expected task
-
Influences retrieval
-
Influences tool selection
-
Influences output
-
Persists across interactions
Step 7 — Validate Security Impact
Section titled “Step 7 — Validate Security Impact”Ask:
Was sensitive data exposed?
Was authorization bypassed?
Was a tool invoked?
Could external communication occur?
Could an enterprise resource be modified?Behavioral deviation alone does not automatically determine severity.
Step 8 — Review Compensating Controls
Section titled “Step 8 — Review Compensating Controls”Even if model behavior changes, determine whether:
Authorization blocked access
Tool policy blocked action
Least privilege limited capability
Human approval prevented executionThese controls significantly affect risk.
Step 9 — Document the Finding
Section titled “Step 9 — Document the Finding”A professional finding should explain the complete attack path.
Example Finding
Section titled “Example Finding”Finding:Indirect Prompt Injection Through Retrieved Documents
Affected Component:Enterprise RAG Assistant
Attack Source:User-controlled knowledge-base document
Attack Path:Document→ RAG Retrieval→ LLM Context→ Model Behavior
Observed Behavior:Instructions contained in retrieved content influencedthe model beyond the intended document-processing task.
Potential Impact:Depending on connected capabilities, malicious contentcould influence responses or downstream agent actions.
Root Cause:Retrieved content is processed by the LLM withoutsufficient separation between reference data and instructions.
Recommendations:- Restrict RAG ingestion sources.- Preserve source provenance.- Enforce authorization-aware retrieval.- Minimize retrieved context.- Restrict agent tools and permissions.- Apply independent authorization to sensitive actions.- Monitor unusual tool behavior.Indirect Prompt Injection Assessment Checklist
Section titled “Indirect Prompt Injection Assessment Checklist”External Sources
Section titled “External Sources”-
External content sources identified.
-
Source ownership documented.
-
User-controlled content identified.
-
Third-party content identified.
Documents
Section titled “Documents”-
Uploaded files treated as untrusted.
-
Content processing occurs safely.
-
Document provenance is tracked.
-
External websites treated as untrusted.
-
Browser tools have restricted permissions.
-
External communication is controlled.
-
Email content treated as untrusted.
-
External senders cannot directly trigger privileged actions.
-
Sensitive actions require confirmation.
-
Ingestion sources are controlled.
-
Authorization is preserved.
-
Document ownership is known.
-
Poisoned content can be removed.
-
Indexes can be rebuilt.
Agents
Section titled “Agents”-
Agent tools are allowlisted.
-
Tool permissions follow least privilege.
-
Security policy exists outside the LLM.
-
High-risk actions require approval.
Monitoring
Section titled “Monitoring”-
Content source can be identified.
-
Retrieval activity is logged.
-
Tool invocation is logged.
-
Policy denials are visible.
-
Suspicious behavior can be investigated.
Common Beginner Mistakes
Section titled “Common Beginner Mistakes”Mistake 1 — Only Testing the Chat Box
Section titled “Mistake 1 — Only Testing the Chat Box”Indirect attacks may arrive through documents, websites, email and APIs.
Mistake 2 — Trusting Internal Documents Automatically
Section titled “Mistake 2 — Trusting Internal Documents Automatically”Internal repositories may still contain user-controlled or compromised content.
Mistake 3 — Trying to Solve Everything With Content Filtering
Section titled “Mistake 3 — Trying to Solve Everything With Content Filtering”Natural language is difficult to perfectly classify.
Mistake 4 — Ignoring RAG Ingestion
Section titled “Mistake 4 — Ignoring RAG Ingestion”Security starts before documents enter the vector database.
Mistake 5 — Giving Browsing Agents Powerful Tools
Section titled “Mistake 5 — Giving Browsing Agents Powerful Tools”Untrusted internet content should not easily influence privileged enterprise actions.
Mistake 6 — Ignoring Tool Output
Section titled “Mistake 6 — Ignoring Tool Output”Tool responses can themselves contain attacker-controlled information.
Mistake 7 — Ignoring Persistence
Section titled “Mistake 7 — Ignoring Persistence”Poisoned RAG content may affect multiple future users.
Mistake 8 — Treating Every Model Deviation as Critical
Section titled “Mistake 8 — Treating Every Model Deviation as Critical”Actual severity depends on available data, tools, permissions and business impact.
Mistake 9 — Relying on the LLM to Authorize Actions
Section titled “Mistake 9 — Relying on the LLM to Authorize Actions”Authorization should exist independently of model reasoning.
Mistake 10 — Forgetting Recovery
Section titled “Mistake 10 — Forgetting Recovery”Organizations should be able to remove poisoned content and rebuild affected indexes.
AI Security Engineer Perspective
Section titled “AI Security Engineer Perspective”When reviewing an AI application, do not only ask:
What can the user type?Ask:
What can the AI read?
Who controls that information?
Can websites influence it?
Can documents influence it?
Can email influence it?
Can RAG influence it?
Can tool responses influence it?
What happens if the model followsinstructions from those sources?
What data could become accessible?
What tools could be invoked?
What independent controls prevent impact?This is the mindset required for enterprise AI security.
Interview Perspective
Section titled “Interview Perspective”You may be asked:
What is Indirect Prompt Injection?
A strong answer is:
Indirect Prompt Injection occurs when attacker-controlled instructions reach an LLM through external content such as documents, websites, emails, RAG sources, API responses or tool output rather than through a direct user prompt. The model may interpret the malicious content as instructions and alter its behavior.
Another question may be:
Why is Indirect Prompt Injection particularly dangerous for AI agents?
A strong answer is:
Agents consume external information and may also have access to tools. If malicious content influences the model’s reasoning or tool selection, the attack can potentially move from manipulating generated text to influencing real actions. Least privilege, independent tool authorization and approval controls are therefore critical.
Another question may be:
How would you protect a RAG system from Indirect Prompt Injection?
A strong answer is:
I would control document ingestion, preserve source provenance, enforce authorization-aware retrieval, minimize retrieved context, treat retrieved documents as untrusted data rather than instructions, restrict downstream agent capabilities and monitor retrieval and tool activity.
Another question may be:
Can Indirect Prompt Injection be completely solved by filtering malicious instructions from documents?
A strong answer is:
Filtering can reduce risk but should not be considered a complete security boundary because natural language instructions can be expressed in many ways. The architecture should assume some malicious content may reach the model and use authorization, least privilege, tool restrictions, output validation and approval controls to contain the impact.
Key Takeaways
Section titled “Key Takeaways”Direct Prompt Injection looks like:
Attacker ↓Prompt ↓LLMIndirect Prompt Injection looks like:
Attacker ↓External Content ↓AI Retrieves Content ↓LLMPotential sources include:
Documents+Websites+Email+RAG+APIs+Databases+Source Code+Tool ResultsThe risk becomes much greater when combined with:
Sensitive Data+AI Agents+Powerful Tools+Excessive Permissions+Autonomous ActionsThe strongest security strategy is not simply:
Detect Every Malicious InstructionIt is:
Treat External Content as Untrusted ↓Control What Reaches the Model ↓Preserve Authorization ↓Restrict Agent Capabilities ↓Enforce Tool Policy ↓Require Approval Where Needed ↓Monitor ActionsMost importantly:
The AI may need to read untrusted content, but untrusted content should never automatically gain authority over enterprise systems.
What’s Next?
Section titled “What’s Next?”➡️ 04 — Jailbreaking and Safety Bypass
You now understand two major prompt-based attack paths:
Direct Prompt Injection +Indirect Prompt InjectionNext, we will examine Jailbreaking and Safety Bypass.
You will learn:
-
What AI jailbreaking means
-
Jailbreaking vs prompt injection
-
Model safety controls
-
Common jailbreak concepts
-
Role and context manipulation
-
Obfuscation
-
Multi-turn attacks
-
Model behavior testing
-
Why successful jailbreaks do not always represent enterprise compromise
-
Security vs AI safety
-
Risk assessment
-
Defense-in-depth strategies
-
Safe and authorized testing methodology
You will move from:
Can Untrusted InstructionsInfluence the Application?to:
Can Adversarial InputsBypass Intended ModelBehavior and Safety Controls?➡️ Next: 04 — Jailbreaking and Safety Bypass