← Back to Blog

Section 6: AI Security and Safety

An agentic system expands the traditional web-application attack surface because untrusted natural language can steer control flow. Never assume a single system prompt or safety filter makes an agent secure—adopt defense-in-depth across every trust boundary.

6.1 The AI Threat Surface & Core Attack Patterns

Agentic AI threat surface and defense-in-depth controls diagram
Figure 5: Agentic AI threat surface and multi-layer defense-in-depth controls across trust boundaries.
  • Direct Prompt Injection: A user crafts input attempting to override system instructions, extract hidden prompts, or trigger unauthorized tools.
  • Indirect Prompt Injection: Malicious instructions hidden inside retrieved documents, emails, web pages, or database records hijack the agent when it reads that content—especially dangerous when the agent holds write or network-egress tools.
  • Data Exfiltration & Excessive Tool Permissions: If an agent combines broad read access with an outbound tool (email, Slack, arbitrary HTTP), an injected instruction can smuggle sensitive data out. Enforce strict least-privilege permissions per tool.
  • Insecure Output Handling: Passing raw model output into SQL queries, shell commands, HTML/Markdown renderers (XSS), or downstream APIs without parameterization and sanitization.

6.2 Data Privacy, Guardrails, Red Teaming, and Governance

  • Privacy & Access Control: Enforce user-level Role-Based Access Control (RBAC) during retrieval—never rely on the LLM to "hide" restricted chunks already in its prompt. Redact PII where unnecessary, avoid logging raw secrets, and verify provider zero-training and retention terms.
  • Multi-Layer Guardrails: Combine input validation, delimited untrusted context, strict tool allowlists and argument schemas, runtime step/cost caps, output sanitization, and mandatory human approval for state-changing actions.
  • Threat Modeling & Red Teaming: For systems you own or are authorized to test, map assets, trust boundaries, and attacker goals (e.g., unauthorized ticket creation or cross-tenant data leak). Run structured red-team suites before major releases and turn discovered bypasses into regression evals.
  • Governance & Production Readiness: Assign clear system ownership, maintain immutable audit logs of approved actions, version prompts and tool schemas under change control, and keep an emergency kill switch to disable autonomous actions without taking down read-only Q&A.