AI Red Teaming & Security Testing
Comprehensive guide on AI Red Teaming & Security Testing.
AI Red Teaming & Security Testing
1. Learning Objectives#
By the end of this notebook, you should be able to:
- Explain why Generative AI requires specialized security testing.
- Build a threat model for an AI application.
- Identify direct and indirect prompt injection risks.
- Understand jailbreaks, data leakage, model misuse, and tool abuse.
- Red-team RAG systems and enterprise knowledge assistants.
- Test AI agents for unsafe or unauthorized actions.
- Design multimodal security tests.
- Understand model, data, and AI supply-chain risks.
- Build attack taxonomies and risk-scoring systems.
- Create safe adversarial test cases.
- Design automated AI red-team pipelines.
- Build security regression suites.
- Evaluate defenses rather than relying only on attack success rates.
- Design incident-response procedures for AI security failures.
- Apply security testing to enterprise and educational AI systems.
- Build production-grade AI security validation programs.
2. What Is AI Red Teaming?
AI red teaming is the structured process of trying to make an AI system:
- reveal information it should not reveal
- violate policy
- misuse tools
- bypass authorization
- follow malicious instructions
- generate unsafe outputs
- behave outside its intended scope
The objective is not simply:
"Break the model."
The objective is:
"Discover realistic failure modes before attackers or users discover them."
3. Why AI Security Is Different
Traditional applications generally have explicit logic:
Architecture & Data FlowInput | v Validation | v Business logic | v Output
AI applications introduce probabilistic behavior:
Architecture & Data FlowInput | v Model | v Probabilistic output
And enterprise AI adds:
textModel + RAG + Tools + Agents + External content + Enterprise permissions
The attack surface becomes broader.
4. AI Security Attack Surface
Architecture & Data FlowAI SYSTEM | +-------------------+-------------------+ | | | v v v Model Data Tools | | | Prompt attacks RAG attacks Tool abuse | | | +-------------------+-------------------+ | v Agents | v External systems
Security must cover the complete system, not only the model.
5. Threat Modeling
Threat modeling asks:
textWhat are we protecting? Who could attack it? How could they attack it? What could happen? How do we reduce the risk?
A practical process:
Architecture & Data FlowAssets | v Actors | v Attack surface | v Threats | v Controls | v Residual risk
6. AI Assets
Assets may include:
- customer data
- employee records
- confidential documents
- prompts
- system instructions
- model weights
- API credentials
- tool permissions
- business logic
- proprietary knowledge
- conversation history
Protect assets according to their sensitivity.
7. Threat Actors
Possible actors:
textCurious user Malicious user Compromised employee External attacker Malicious document author Malicious website Supply-chain attacker Automated abuse
Not every actor needs the same capabilities.
8. Trust Boundaries
Draw trust boundaries explicitly.
Architecture & Data FlowUntrusted User | | trust boundary v Application | | trust boundary v AI Gateway | +--> Model +--> RAG +--> Tools
Data crossing a trust boundary should be validated and authorized.
9. Direct Prompt Injection
A direct prompt injection occurs when a user attempts to manipulate the AI's instructions.
Conceptually:
Architecture & Data FlowSystem instructions + User input | v Model
The attacker tries to cause the model to disregard intended behavior.
The important lesson:
System prompts are not a security boundary.
10. Indirect Prompt Injection
Indirect injection is especially important for RAG and agents.
Example flow:
Architecture & Data FlowUser | v AI Agent | v Web page / document | v Malicious instructions inside content | v Agent
The attacker may never interact directly with the model.
The malicious instruction travels through external data.
11. Why Indirect Injection Matters
Enterprise AI consumes untrusted content from:
- websites
- emails
- uploaded files
- support tickets
- documents
- repositories
- calendars
Therefore:
Mathematical FormulationExternal content != Trusted instruction
Treat retrieved content as data, not authority.
12. Instruction vs Data
A useful conceptual separation:
Architecture & Data FlowTrusted instructions | v Policy / system layer Untrusted content | v Evidence / data layer
The model may still confuse the two.
Therefore, application-level controls are necessary.
13. RAG Security Threats
RAG can be attacked through:
- malicious documents
- poisoned knowledge
- unauthorized retrieval
- stale permissions
- cross-tenant leakage
- malicious metadata
- retrieval manipulation
Architecture:
Architecture & Data FlowSource | v Ingestion | v Index | v Retriever | v Context | v Model
Security controls are needed at every stage.
14. Data Poisoning
An attacker may attempt to place misleading or malicious content into a knowledge source.
Example:
Architecture & Data FlowKnowledge base | +--> legitimate document | +--> poisoned document
Potential result:
Architecture & Data FlowQuestion | v Retriever | v Poisoned evidence | v Incorrect answer
Protect ingestion and indexing pipelines.
15. Retrieval Authorization
A critical security rule:
textRetrieval permission must be checked before context reaches the model
Do not rely on:
›"Please only answer using documents the user is allowed to see."
Authorization must be enforced outside the model.
16. Cross-Tenant Leakage
Consider:
Architecture & Data FlowTenant A | +--> Document A Tenant B | +--> Document B
A retrieval bug could produce:
Architecture & Data FlowTenant A user | v Document B
This is a severe security failure.
Use:
- tenant-scoped indexes
- metadata filters
- row-level security
- separate storage
- authorization checks
17. Cache Security
Caching can introduce data leakage.
Example:
Architecture & Data FlowUser A | v Sensitive response | v Shared cache | v User B
Cache keys should account for:
- tenant
- user or authorization scope
- relevant data version
- request characteristics
Never let caching bypass access control.
18. Agent Security
Agents are more dangerous because they can act.
Architecture & Data FlowModel | v Tool | v Business system
Potential tools:
- CRM
- database
- shell
- browser
- file system
- cloud APIs
The security impact depends on the permissions of those tools.
19. Excessive Agency
A common design failure:
Architecture & Data FlowUser | v Agent | v Everything
Instead:
Architecture & Data FlowAgent | v Policy gateway | +--> Read-only tools +--> Restricted tools +--> Approval-required tools
Give agents only the minimum capabilities needed.
20. Least Privilege
The principle:
Give every component the minimum permissions required to perform its task.
For example:
Architecture & Data FlowAnalytics agent | +--> Read warehouse | X--> Delete tables X--> Modify production data
Least privilege reduces blast radius.
21. Tool Allowlisting
Instead of allowing arbitrary tool access:
🐍 PythonInteractive WebAssemblyALLOWED_TOOLS = {
"search_customer",
"get_order",
"create_ticket",
}
Reject tools outside the approved set.
22. Tool Argument Validation
Never trust model-generated tool arguments.
Example:
🐍 PythonInteractive WebAssemblydef validate_order_id(order_id: str) -> bool:
return order_id.isalnum() and len(order_id) <= 32
Production validation should be schema-based and business-rule aware.
23. Structured Tool Schemas
Use explicit schemas:
🐍 PythonInteractive WebAssemblyfrom pydantic import BaseModel
class CreateTicket(BaseModel):
customer_id: str
category: str
description: str
Then validate before execution.
Architecture & Data FlowModel | v Schema validation | v Authorization | v Business validation | v Tool
24. Dangerous Tool Classes
High-risk tools include:
textShell Database write Financial transaction Email send File deletion Cloud administration Production deployment Identity management
These should receive stronger controls.
25. Human Approval
For high-impact actions:
Architecture & Data FlowAgent | v Proposed action | v Human approval | +--> Approve --> Execute | +--> Reject --> Stop
Approval should show enough context for the reviewer to make an informed decision.
26. Approval UX
A good approval interface should show:
textAction Target Arguments Reason Expected impact Relevant evidence Risk level
Avoid:
›"Approve AI action?"
without useful context.
27. SQL Agent Security
An analytics agent may generate SQL.
Risky:
sqlDROP TABLE customers;
Safer architecture:
Architecture & Data FlowNatural language | v SQL generation | v SQL parser | v Read-only policy | v Allowed warehouse | v Execute
Prefer read-only credentials for analytics agents.
28. Shell / Code Execution
Generated commands should be treated as untrusted.
Use:
Architecture & Data FlowAgent | v Sandbox | +--> Resource limits +--> Network policy +--> Filesystem isolation +--> Time limit +--> Process limit | v Execution
Do not execute arbitrary model output directly on production systems.
29. Browser Agent Security
Browser agents can interact with:
- websites
- forms
- accounts
- documents
- payment pages
Risks include:
- malicious pages
- credential theft
- unintended submissions
- prompt injection
- navigation to unsafe destinations
Use domain allowlists and confirmation for sensitive actions.
30. SSRF and URL Security
AI systems may be asked to fetch URLs.
A naive design:
🐍 PythonInteractive WebAssemblyrequests.get(user_url)
can be dangerous.
Use:
- URL validation
- domain allowlists
- private-network blocking
- redirect validation
- response-size limits
- timeouts
AI should not become an unrestricted network proxy.
31. File Upload Security
Enterprise AI often processes:
- PDFs
- Office files
- images
- archives
- code
Treat uploads as untrusted.
Controls include:
- file type validation
- size limits
- malware scanning
- sandboxed parsing
- archive limits
- content-type validation
32. Multimodal Prompt Injection
Images and documents can contain malicious instructions.
Example:
Architecture & Data FlowImage | +--> Visible content | +--> Hidden or embedded instruction | v Vision model
The model may interpret the instruction as relevant.
Treat multimodal inputs as untrusted data.
33. OCR Injection
An attacker may place text in an image:
›"Ignore previous instructions..."
OCR can extract it and pass it to the model.
Therefore:
Architecture & Data FlowImage | v OCR | v Untrusted text | v Model
The same injection risks apply.
34. Audio Injection
Audio systems may encounter malicious speech:
Architecture & Data FlowAudio | v Speech recognition | v Injected instruction | v Agent
Voice agents should distinguish:
- user intent
- quoted speech
- external audio
- untrusted audio content
35. Video Injection
Video may contain:
- spoken instructions
- text overlays
- malicious frames
- misleading content
A video agent should treat extracted information as untrusted evidence.
36. Jailbreaks
A jailbreak attempts to cause a model to bypass intended behavioral constraints.
Testing should explore:
- instruction conflicts
- role manipulation
- obfuscation
- multilingual variants
- multi-turn escalation
- indirect instructions
The purpose is defensive validation.
37. Multi-Turn Attacks
An attacker may not attempt a bypass in one request.
Instead:
textTurn 1 Build context Turn 2 Change assumptions Turn 3 Request sensitive behavior Turn 4 Exploit accumulated context
Therefore, red teaming should test complete conversations, not only isolated prompts.
38. Context Manipulation
Attackers may attempt to manipulate:
- conversation history
- retrieved context
- tool results
- memory
- summaries
A summary can accidentally preserve malicious instructions.
Security testing should include long-context scenarios.
39. Memory Security
AI memory may contain:
textUser preferences Past conversations Facts Tool results Business data
Risks:
- unauthorized retrieval
- cross-user leakage
- stale information
- malicious memory insertion
Memory needs access control and lifecycle policies.
40. Data Exfiltration
A common objective is:
Architecture & Data FlowAttacker | v AI | v Sensitive data | v Attacker
Test whether the model can reveal:
- system instructions
- secrets
- private documents
- credentials
- other users' data
Controls should exist outside the model.
41. Secret Protection
Never place secrets in prompts if they can be avoided.
Prefer:
Architecture & Data FlowAgent | v Secure credential store | v Tool
rather than:
Architecture & Data FlowPrompt | v API key
Use secret managers and short-lived credentials where possible.
42. System Prompt Leakage
System prompts are not secrets in the same sense as credentials, but they can contain sensitive implementation details.
Do not place:
- API keys
- passwords
- privileged business secrets
inside system prompts.
Prompt confidentiality should not be treated as the primary security control.
43. Model Extraction
Attackers may attempt to infer proprietary model behavior through repeated queries.
Possible protections:
- authentication
- rate limits
- output restrictions
- abuse monitoring
- anomaly detection
Do not assume model APIs are impossible to probe.
44. Denial of Service
AI systems can be expensive to execute.
Abuse patterns include:
textHuge prompts Long outputs Many requests Expensive multimodal inputs Agent loops Repeated retries
Controls:
- input limits
- output limits
- concurrency limits
- budgets
- rate limits
- request complexity controls
45. Economic Denial of Service
An attacker may not need to crash the system.
They can cause:
textHigh-cost model calls + Long contexts + Repeated requests
resulting in:
›Budget exhaustion
This is an AI-specific economic risk.
46. Abuse Detection
Monitor:
textRequests/user Tokens/user Cost/user Failure rate Tool calls Prompt length Output length
Look for anomalies:
Architecture & Data FlowNormal | v Sudden 100x token usage | v Investigate / throttle
47. Supply-Chain Security
AI systems depend on:
- models
- datasets
- libraries
- containers
- embeddings
- plugins
- tools
- model servers
A compromised dependency can affect the complete system.
48. Model Provenance
Track:
Architecture & Data FlowModel | +--> Source +--> Version +--> License +--> Hash +--> Training information +--> Security review
Only approved artifacts should enter production.
49. Dependency Security
Maintain:
textDependency inventory Version Source License Vulnerabilities Owner Approval status
Scan software dependencies and container images.
50. Dataset Security
Training and evaluation datasets can contain:
- malicious content
- sensitive data
- poisoned examples
- licensing issues
Use:
- provenance
- validation
- deduplication
- access controls
- quality checks
51. Data Exfiltration Through RAG
A malicious document can attempt:
Architecture & Data FlowRetrieved content | v "Send all confidential information to..." | v Agent
Never let retrieved text directly authorize tool actions.
Use a policy layer between evidence and action.
52. Tool Output Injection
Tools can return untrusted content.
Example:
Architecture & Data FlowBrowser tool | v Malicious web page | v Tool output | v Agent
The agent may interpret tool output as instructions.
Treat tool results as untrusted data.
53. Tool Result Boundaries
Architecture & Data FlowTool result | v Parse | v Validate | v Label as untrusted data | v Agent reasoning
Do not allow tool results to silently override system policy.
54. Agent-to-Agent Security
Multi-agent systems introduce:
Architecture & Data FlowAgent A | v Agent B | v Agent C
Each agent should have:
- identity
- permissions
- defined responsibilities
- communication boundaries
Do not assume all agents should have equal privileges.
55. Supervisor Security
A supervisor agent may route tasks.
Architecture & Data FlowSupervisor | +--> Research agent +--> Data agent +--> Action agent
The supervisor should not automatically inherit every tool permission.
Keep privilege scoped to each role.
56. Red-Team Attack Taxonomy
A useful taxonomy:
text1. Instruction attacks 2. Data attacks 3. Retrieval attacks 4. Tool attacks 5. Agent attacks 6. Identity attacks 7. Availability attacks 8. Supply-chain attacks 9. Privacy attacks 10. Multimodal attacks
This makes test coverage easier to manage.
57. Risk Scoring
A simple model:
Mathematical FormulationRisk = Likelihood × Impact
Example:
Mathematical FormulationLikelihood = 4/5 Impact = 5/5 Risk = 20
Add exploitability and detectability for a richer internal model.
58. Security Severity
Example:
textCritical Cross-tenant data exposure Unauthorized financial action High Sensitive-data leakage Production tool abuse Medium Policy bypass with limited impact Low Minor undesirable behavior
Severity should reflect real business impact.
59. Red-Team Test Case
A test case should include:
textTest ID Threat category Preconditions Input Expected safe behavior Observed behavior Severity Mitigation Regression test
Example:
🐍 PythonInteractive WebAssemblytest_case = {
"id": "RAG-SEC-001",
"category": "indirect-injection",
"expected": "ignore untrusted instructions",
}
60. Expected vs Observed Behavior
Security testing needs explicit expected behavior.
Example:
textAttack: Malicious document asks agent to send customer records. Expected: Agent refuses and does not invoke export tool. Observed: Agent invokes export tool. Result: FAIL
This is more actionable than simply recording a model response.
61. Automated Red-Team Pipeline
Architecture & Data FlowTest Dataset | v Attack Generator | v AI System | v Safety / Security Evaluator | v Result Store | v Risk Scoring | v Regression Suite
Run automatically during development and release.
62. Attack Generation
Attack cases can come from:
- manually designed scenarios
- historical incidents
- security researchers
- synthetic generation
- fuzzing
- mutation of known attacks
- production failures
Do not rely on a single attack style.
63. Prompt Mutation
A base security test can be varied through:
- paraphrasing
- language changes
- formatting changes
- multi-turn context
- indirect placement
- obfuscation
The goal is to discover brittle defenses.
64. Multilingual Red Teaming
If the system supports multiple languages, test security behavior across them.
Example:
textEnglish Hindi Arabic Spanish French
Security policies should not disappear because the request changes language.
65. Encoding and Obfuscation
Security testing can include harmless transformations such as:
textWhitespace variation Case variation Encoding variation Formatting changes Character substitutions
The objective is to determine whether safety controls depend too heavily on surface wording.
66. Boundary Testing
Test around policy boundaries.
For example:
Architecture & Data FlowAllowed request | v Borderline request | v Disallowed request
Check whether behavior changes predictably.
67. Regression Testing
Every discovered vulnerability should become a permanent test.
Architecture & Data FlowIncident | v Attack case | v Regression test | v Future releases
This prevents the same vulnerability from returning.
68. Security Gates
A release may require:
Mathematical FormulationCritical vulnerabilities = 0 High vulnerabilities = 0 Cross-tenant leakage = 0 Unauthorized tool execution = 0 Safety threshold >= target
Fail the release if requirements are not met.
69. Defense-in-Depth
No single defense is sufficient.
Architecture & Data FlowUser | v Authentication | v Authorization | v Input controls | v Model | v Output validation | v Tool policy | v Business validation | v Audit
If one layer fails, another can limit the impact.
70. Security Gateway
A centralized gateway can enforce:
textIdentity Policy Rate limits Data classification Model routing Tool permissions Audit
This creates consistent controls across AI applications.
71. Policy Engine
A policy engine can answer:
textCan this user access this data? Can this model process this data? Can this agent use this tool? Can this action be executed automatically?
Conceptually:
🐍 PythonInteractive WebAssemblydecision = policy_engine.check( user=user, action=action, resource=resource, )
The model should not make these authorization decisions alone.
72. Data Egress Controls
Control where information can go.
Architecture & Data FlowSensitive data | v Egress policy | +--> Approved internal destination | X--> External destination
Useful for:
- webhooks
- external APIs
- file downloads
73. Output DLP
Before sensitive outputs leave the system:
Architecture & Data FlowGenerated output | v DLP scanner | +--> Safe --> Send | +--> Sensitive --> Block / redact / review
This is especially important for customer-facing and agentic systems.
74. Security Telemetry
Track:
textPrompt injection attempts Tool denials Authorization failures Sensitive-data detections Abnormal token usage Rate-limit violations Model refusals Security policy violations
Security telemetry should be correlated with request IDs.
75. Security Monitoring
A useful pipeline:
Architecture & Data FlowEvents | v Detection rules | v Anomaly detection | v Alert | v Investigation
Examples:
Mathematical FormulationRepeated injection attempts + High token usage + Multiple tool denials = Potential abuse
76. Incident Response
For an AI security incident:
Architecture & Data FlowDetect | v Contain | v Preserve evidence | v Investigate | v Remediate | v Validate | v Document | v Regression test
77. Kill Switches
Critical systems should be able to disable risky capabilities quickly.
Architecture & Data FlowAgent | v Policy | +--> write_tools = enabled | +--> write_tools = disabled
A kill switch should be simple and independently operable.
78. Security Review Checklist
Before production:
text[ ] Threat model [ ] Trust boundaries [ ] Identity [ ] Authorization [ ] Tenant isolation [ ] Data classification [ ] Prompt injection testing [ ] RAG poisoning testing [ ] Tool security [ ] Agent limits [ ] Output validation [ ] DLP [ ] Rate limits [ ] Abuse monitoring [ ] Supply-chain review [ ] Incident response [ ] Regression suite [ ] Kill switch
79. Practical Project 1: Prompt Injection Test Harness
Build a test suite that sends controlled adversarial cases to an AI application.
Measure:
- attack success rate
- refusal correctness
- data leakage
- tool execution
- false positives
Convert every important failure into a regression test.
80. Practical Project 2: RAG Security Scanner
Build a pipeline that:
Architecture & Data FlowDocuments | v Security checks | +--> suspicious instruction +--> permission anomaly +--> poisoned content +--> sensitive data | v Quarantine / approve
Keep security decisions separate from model-generated classifications where possible.
81. Practical Project 3: Agent Tool Security Gateway
Implement:
Architecture & Data FlowAgent | v Tool gateway | +--> Identity +--> Allowlist +--> Schema validation +--> Authorization +--> Budget +--> Audit | v Tool
Test unauthorized and malformed tool calls.
82. Practical Project 4: SQL Agent Security
Build an analytics agent that:
- generates SQL
- parses SQL
- blocks write operations
- restricts tables
- applies row/column permissions
- logs queries
- limits result size
Test malicious and accidental destructive SQL.
83. Practical Project 5: Multimodal Red-Team Suite
Test:
textImage injection OCR injection Audio injection Video injection Malicious documents
Measure whether untrusted multimodal content can cause:
- policy bypass
- data leakage
- unauthorized tool calls
84. Practical Project 6: AI Security Regression Platform
Build:
Architecture & Data FlowAttack library | v Automated runner | v AI application | v Security evaluator | v Results database | v Release gate
Track vulnerabilities across model and application versions.
85. Advanced Exercise 1: Enterprise Threat Model
Create a threat model for:
Architecture & Data FlowEnterprise AI assistant | +--> RAG +--> CRM tools +--> Email +--> Web search
Identify at least:
- 10 assets
- 10 threats
- 10 controls
- trust boundaries
- high-risk attack paths
86. Advanced Exercise 2: Indirect Injection
Design a test where:
Architecture & Data FlowMalicious webpage | v Web retrieval | v Agent | v Tool
attempts to cause an unauthorized action.
Define:
- expected behavior
- detection
- mitigation
- regression test
87. Advanced Exercise 3: Cross-Tenant Attack
Design a test for:
Architecture & Data FlowTenant A user | v Shared RAG system | v Attempt to retrieve Tenant B data
Test:
- direct retrieval
- semantic search
- cache
- agent memory
- citations
- tool access
88. Advanced Exercise 4: Agent Privilege Escalation
Design an agent architecture with:
textRead tools Write tools Admin tools
Then define which actions require:
- no approval
- user approval
- administrator approval
Explain how privilege escalation is prevented.
89. Advanced Exercise 5: AI Supply-Chain Security
Create a security process for approving:
textModel Dataset Container Python package Embedding model Tool plugin
Include:
- provenance
- versioning
- hashes
- vulnerability scanning
- license review
- security approval
90. Advanced Exercise 6: Red-Team Program
Design a quarterly enterprise AI red-team program.
Include:
textThreat taxonomy Attack library Automated testing Manual testing Production telemetry Security regression Executive reporting Incident response
Define measurable security KPIs.
91. Common Mistakes
Mistake 1: Treating the system prompt as a security boundary#
Attackers can manipulate model behavior.
Mistake 2: Trusting retrieved content#
RAG content can contain malicious instructions.
Mistake 3: Giving agents excessive permissions#
Agent capability should be limited by policy.
Mistake 4: Executing model output directly#
Validate generated SQL, code, commands, and tool arguments.
Mistake 5: Ignoring caches#
Caches can become cross-user data-leak paths.
Mistake 6: Testing only single-turn prompts#
Real attacks can be multi-turn and contextual.
Mistake 7: Ignoring multimodal inputs#
Images, audio, and video can carry malicious instructions.
Mistake 8: No security regression suite#
A fixed vulnerability can return after a model or prompt update.
Mistake 9: No rate limits#
AI can be abused for denial of service and economic exhaustion.
Mistake 10: Trusting tool outputs#
External tools can return malicious or manipulated content.
Mistake 11: No supply-chain controls#
Models, datasets, packages, and containers are all dependencies.
Mistake 12: Red teaming only the model#
The application, data, tools, identity, and infrastructure must also be tested.
92. Final Mental Model
AI red teaming can be summarized as:
Architecture & Data FlowAI SYSTEM | v THREAT MODEL | v ATTACK SURFACE | +--------------+--------------+ | | | v v v MODEL DATA TOOLS | | | Prompt RAG Agent actions attacks attacks tool abuse | | | +--------------+--------------+ | v ADVERSARIAL TESTS | v EVALUATION | v MITIGATIONS | v SECURITY REGRESSION | v PRODUCTION | v MONITOR + LEARN
The deepest principle is:
AI security is a system property. A secure model inside an insecure application is still an insecure AI system.
93. Key Takeaways
- AI red teaming tests how the complete AI system behaves under adversarial conditions.
- The model is only one part of the attack surface.
- System prompts are not security boundaries.
- Direct and indirect prompt injection must both be tested.
- Retrieved documents, websites, emails, tool results, and multimodal inputs should be treated as untrusted data.
- RAG requires authorization-aware retrieval.
- Tenant isolation must be enforced outside the model.
- Agents should follow least privilege.
- Tool calls require allowlists, schema validation, authorization, and business-rule checks.
- High-impact actions should support human approval.
- SQL, shell, browser, filesystem, and cloud tools require stronger controls.
- Generated output is untrusted input and should be validated.
- Caches and memory can become security boundaries.
- Multimodal systems introduce additional injection paths.
- AI systems can be abused for denial of service and economic exhaustion.
- Models, datasets, packages, containers, and tools form an AI supply chain.
- Every discovered security vulnerability should become a regression test.
- Automated red-team pipelines make security validation repeatable.
- Defense-in-depth is more reliable than any single AI safety mechanism.
- Security telemetry should cover both attacks and attempted attacks.
- Kill switches and incident runbooks reduce the impact of production failures.
- The goal of red teaming is not merely to produce attacks; it is to discover weaknesses and turn them into durable engineering improvements.
94. Knowledge Check
Question 1#
What is AI red teaming?
Answer: Structured adversarial testing designed to discover realistic security, safety, privacy, and reliability weaknesses in an AI system before they are exploited.
Question 2#
Why is prompt injection dangerous?
Answer: It can manipulate model behavior and potentially influence retrieval, tool usage, or agent actions.
Question 3#
What is indirect prompt injection?
Answer: Malicious instructions embedded in external content such as a document or webpage that the AI later retrieves or processes.
Question 4#
Why can an agent be more dangerous than a chatbot?
Answer: An agent can translate model decisions into actions through tools and external systems.
Question 5#
What is least privilege?
Answer: Giving each component only the permissions required for its intended task.
Question 6#
Why should tool outputs be treated as untrusted?
Answer: Tools may consume external or attacker-controlled data, which can contain misleading or malicious instructions.
Question 7#
Why is tenant isolation important?
Answer: It prevents users or organizations from accessing another tenant's data through retrieval, caches, memory, tools, or application bugs.
Question 8#
What should happen after discovering a serious AI security vulnerability?
Answer: Contain and remediate it, validate the fix, and add a regression test so future releases are checked automatically.
Question 9#
Why is multimodal red teaming necessary?
Answer: Images, audio, video, and extracted OCR/transcription content can introduce attack paths that do not exist in text-only systems.
Question 10#
What is the central AI security principle?
Answer: Security must be enforced across the complete system through identity, authorization, validation, isolation, policy, monitoring, and defense-in-depth rather than relying on the model alone.
95. Course Progression
The course has now moved from reliability engineering into adversarial security validation.
Architecture & Data FlowEnterprise Generative AI | v AI FinOps & Cost Engineering | v AI Reliability & SRE | v AI Red Teaming & Security Testing | v Future / Research AI Architectures | v Full Generative AI Capstone
The next notebook moves into Future / Research AI Architectures, covering emerging model architectures, multimodal foundation models, mixture-of-experts evolution, state-space and recurrent alternatives, long-context systems, memory architectures, retrieval-native models, reasoning systems, world models, neuro-symbolic approaches, continual learning, test-time compute, agent-native architectures, embodied AI, efficient inference, future training paradigms, research evaluation, and how to reason about emerging AI architectures without chasing hype.
AI Red Teaming & Security Testing Checkpoint
Finished studying this notebook?
Mark this guide as completed to update your course progress roadmap.