Artificial intelligence • Original RRTutors lesson
AI Security, Privacy, and Prompt-Injection Defense
Protect model-based applications from data exposure, malicious inputs, unsafe tool use, and supply-chain risks.
Concept and explanation
AI-specific threats include prompt injection, retrieval poisoning, sensitive-data leakage, unsafe output execution, model theft, and denial-of-service through expensive inputs. Natural-language instructions are not an authorization mechanism. Enforce permissions in ordinary application code, constrain tools, minimize data, and log security-relevant events safely.
How to apply it
Threat-model user, retrieved, and model-generated content as untrusted; apply least privilege, output validation, rate limits, and human approval for consequential actions.
Worked example
A model may propose a refund, but the application should independently check user authorization, transaction state, and refund policy before executing it.
Illustrative Python example
proposal = model_suggested_action
if authorized(user, proposal) and policy_allows(proposal):
execute(proposal)
else:
require_review(proposal)
Expected result
Application-side authorization and policy checks remain authoritative.
Limitations and cautions
Filters and prompts alone cannot guarantee security; every connected tool and data path expands the attack surface.
Practice exercise
Threat-model an assistant that can search documents and create support tickets; list trust boundaries and controls.
Key takeaway: Never let generated text grant itself permissions.