AI Security

Secure Enterprise AI Architecture

Defense-in-depth security framework protecting production AI systems from indirect prompt injection, data exfiltration, jailbreaks, and adversarial poisoning.

By Bhavin Mistry, Senior Engineering Manager at Commonwealth Bank Published: 2026-08-12 Last updated: 2026-09-22 13 min read
Table of Contents (9 sections)
SYSTEM TOPOLOGY & DATA FLOW ENTERPRISE SPECIFICATION
Client Application RBAC Context Security & Gateway PII Sanitization Semantic Cache Check Rate & Token Budget Inference & Rerank BM25 + Vector Fusion Cross-Encoder Top-5 Grounded Synthesis Telemetry OpenTelemetry

The Core Problem Solved

LLMs inherently blur the line between control logic (system instructions) and untrusted user input, opening severe vulnerabilities to indirect injection via external data.

When To Deploy This Architecture

Customer-facing agents, systems reading public emails/documents, and any AI application with tool-execution privileges.

Architectural Components

  • Input Sanitizer & Classifier (NeMo Guardrails / Llama Guard)
  • Dual-LLM Architecture (Isolated untrusted data processor vs privileged executive LLM)
  • Tool Permission Boundary & Output Whitelisting
  • Egress Firewall (Deny-by-default external network access)
  • Canary Token Trap System

Data Flow Narrative

User Input -> Prompt Guardrail -> Dual-LLM Context Encapsulation -> Controlled Tool Execution with Human Confirmation -> Output Content Filter -> Secure Response Delivery.

Security & Perimeter Control

Zero trust architecture; assumption that all third-party fetched content is malicious; canary tokens embedded in system prompts to alert on extraction attempts.

Governance & Telemetry

Alignment with OWASP Top 10 for LLM Applications and NIST AI Risk Management Framework (RMF).

Identified Failure Modes & Mitigations

High false-positive rate blocking benign user queries; latency degradation through multi-stage guardrail evaluation.

Production Code Implementation

Copy-paste ready implementation snippet demonstrating the core architectural boundary logic:

dual_llm_perimeter.py
# Dual-LLM Quarantine & Canary Trap Defense Pattern
import secrets

class SecureAIPerimeter:
    def __init__(self, privileged_llm, quarantine_llm):
        self.privileged_llm = privileged_llm
        self.quarantine_llm = quarantine_llm

    def execute_safely(self, user_query: str, untrusted_doc: str) -> str:
        canary = f"CANARY_{secrets.token_hex(8)}"
        
        # 1. Quarantine LLM parses untrusted document (Zero tool execution privileges)
        facts = self.quarantine_llm.generate(
            f"Extract verified structured facts answering: {user_query}\nSource:\n{untrusted_doc}"
        )
        
        # 2. Privileged LLM executes with canary guard
        prompt = f"FENCE:{canary}\nUsing verified facts only: {facts}\nAnswer: {user_query}"
        response = self.privileged_llm.generate(prompt)
        
        # 3. Canary detection check
        if canary in response:
            raise SecurityVulnerability("Prompt injection detected: canary token leaked!")
        return response
Architectural Q&A

Frequently Asked Questions

How does the Dual-LLM architecture prevent indirect prompt injection?
An unprivileged quarantine LLM extracts structured facts from untrusted third-party documents/emails without tool capabilities. The privileged executive LLM only receives sanitized, schema-validated payloads, completely breaking injection execution chains.
What is a canary token trap in GenAI security?
A unique cryptographic token embedded into system prompts. If a prompt extraction attack occurs and the token appears in output streams or network egress, sessions are immediately severed and security incident alerts trigger.
Engineering Resource

The Enterprise AI Production Checklist

A rigorous 50-point engineering, security, and FinOps verification gate before promoting Generative AI and Agentic systems to live enterprise traffic.

Zero spam. Fortnightly dispatches. Unsubscribe anytime.
Author & Engineering Leader

Bhavin Mistry

Senior Engineering Manager at Commonwealth Bank based in Melbourne, Australia. Focusing on enterprise AI architecture, hybrid RAG, agentic reliability, and technology economics.

Connected Tools & Frameworks

Cross-Referenced Production Resources

Methodology

5-Stage Maturity Framework

Stage gates from exploration to hardened multi-region deployment.

Assessment

AI Readiness Diagnostic

Benchmark organizational readiness across 12 operational dimensions.

FinOps

RAG Cost Calculator

Model vector storage, query volume, and caching ROI accurately.