Skip to content
ML to LLMs
Cheat sheets

Security controls

Threats to LLM applications and the enforceable controls that contain them.

Principle: assume the model can be manipulated; make sure a manipulated model can't do much harm.

ThreatControl
Direct prompt injectionenforce policy in code; no secrets in prompts; output filtering
Indirect prompt injection (in documents, pages, emails, tool outputs)label untrusted content; task-scoped tool allowlists; validate actions; human approval
Data exfiltration (links, images, encoded data)restrict or allowlist outbound URLs and rendered images
Tool abuse / excessive permissionsper-user, least-privilege credentials; argument schemas; rate limits
Secret leakagekeep keys server-side; redact logs
Unsafe generated SQL or codeparse and allowlist; read-only roles; sandbox without network; resource limits
Privacy violationspermission filters at retrieval; data minimization; retention limits
Supply chaintrusted model sources, checksums, safe serialization, pinned dependencies
Missing accountabilityaudit logs with request, retrieved IDs, tool calls, and versions

Layered defense math: harm per attempt =pinj∏ipcontroli= p_{\text{inj}}\prod_i p_{\text{control}_i}; removing a capability sets its term to zero.

Test: keep injection, exfiltration, and privilege-escalation cases in the evaluation set; gate releases on attack success rate; red-team regularly. Demonstrate attacks only with mocked tools.

Lessons: Securing AI systems · Production architecture