Defense-in-Depth Architecture

How EnforceCore fits into a layered security deployment for AI agent systems.


Overview

Defense-in-depth is the principle that no single security layer is sufficient. Each layer protects against threats that others cannot detect or prevent. EnforceCore occupies the runtime enforcement layer โ€” it understands agent-level semantics (tool calls, PII, cost budgets) that OS-level mechanisms cannot see.

This document describes:

  1. The five security layers relevant to AI agent deployments
  2. What each layer catches (and what it misses)
  3. Recommended deployment stacks
  4. Gap analysis: threats that fall between layers

The Five Layers

graph TB
    subgraph "Defense-in-Depth Stack"
        A["๐Ÿ”’ Hardware Layer<br/>TPM ยท SGX ยท TrustZone"]
        B["๐Ÿง OS/Kernel Layer<br/>SELinux ยท AppArmor ยท seccomp-bpf ยท Capabilities"]
        C["๐Ÿ“ฆ Container Layer<br/>Docker ยท Kubernetes ยท gVisor ยท Firecracker"]
        D["โš™๏ธ Runtime Layer<br/>EnforceCore"]
        E["๐Ÿ’ฌ Prompt Layer<br/>NeMo Guardrails ยท LlamaGuard ยท Content filters"]
    end

    A --> B --> C --> D --> E

    style D fill:#2d7d46,stroke:#1a5c30,color:#fff

Layer 1: Hardware Root of Trust

Components TPM 2.0, Intel SGX/TDX, ARM TrustZone
Catches Firmware tampering, physical key extraction, boot-chain attacks
Misses Everything above the hardware boundary
EnforceCore interaction None โ€” hardware trust is assumed

Layer 2: OS/Kernel Enforcement

Components SELinux, AppArmor, seccomp-bpf, Linux capabilities, namespaces
Catches Unauthorized syscalls, file access outside policy, raw socket creation, privilege escalation via kernel exploits
Misses Application-level semantics โ€” cannot distinguish write_file("report.pdf") from write_file("ransomware_payload") because both are the same syscall
EnforceCore interaction SELinux/AppArmor constrains the Python process. EnforceCore constrains what the agent does within that process. Complementary.

Layer 3: Container Isolation

Components Docker, Kubernetes Pods, gVisor, Firecracker, cgroups
Catches Process escape, resource exhaustion (CPU/memory/disk), cross-container network access
Misses Agent-level behavior within the container โ€” a containerized agent can still call denied tools, leak PII, or exceed cost budgets
EnforceCore interaction Containers provide the execution boundary. EnforceCore provides the policy boundary within that container.

Layer 4: Runtime Enforcement (EnforceCore)

Components EnforceCore policy engine, PII redaction, audit trail, resource guard
Catches Denied tool calls, PII in inputs/outputs, cost/rate limit violations, oversized outputs, tool-name spoofing, content rule violations
Misses Threats below the Python runtime (kernel exploits, container escape), threats above it (prompt injection that doesn't result in tool calls)
EnforceCore interaction This is EnforceCore.

Layer 5: Prompt/Content Layer

Components NeMo Guardrails, LlamaGuard, custom content filters
Catches Prompt injection, toxic content, off-topic responses, jailbreak attempts
Misses Agent actions โ€” even if the LLM output is classified as "safe," the resulting tool call may violate policy
EnforceCore interaction Prompt filters clean LLM output before it reaches the agent. EnforceCore enforces what the agent does with that output.

Threat Coverage Matrix

Which layer catches which threat:

Threat Hardware OS/Kernel Container EnforceCore Prompt
Firmware rootkit โœ… โŒ โŒ โŒ โŒ
Kernel privilege escalation โŒ โœ… โœ… โŒ โŒ
Container escape โŒ โœ… โœ… โŒ โŒ
Unauthorized syscall โŒ โœ… โŒ โŒ โŒ
Denied tool invocation โŒ โŒ โŒ โœ… โŒ
PII exfiltration via tool โŒ โŒ โŒ โœ… โŒ
Cost budget overrun โŒ โŒ โŒ โœ… โŒ
Rate limit abuse โŒ โŒ โŒ โœ… โŒ
Tool-name spoofing โŒ โŒ โŒ โœ… โŒ
Oversized output exfiltration โŒ โŒ โŒ โœ… โŒ
Multi-stage ransomware โŒ โŒ โŒ โœ… โŒ
Prompt injection โŒ โŒ โŒ โŒ โœ…
Toxic LLM output โŒ โŒ โŒ โŒ โœ…
CPU/memory exhaustion โŒ โŒ โœ… โœ…* โŒ

* EnforceCore provides time limits and cost budgets. Containers provide hard resource limits (cgroups). Both are needed.


Minimum Viable Security

For development and testing:

Python process
  โ””โ”€โ”€ EnforceCore (policy enforcement)

Sufficient for: development, CI/CD testing, policy validation.

Not sufficient for: production with untrusted agents.

Standard Production

For production deployments with trusted agents:

Container (Docker / Kubernetes Pod)
  โ”œโ”€โ”€ seccomp profile (block dangerous syscalls)
  โ”œโ”€โ”€ Read-only filesystem
  โ”œโ”€โ”€ Dropped capabilities (no CAP_NET_RAW, CAP_SYS_ADMIN)
  โ””โ”€โ”€ Python process
      โ””โ”€โ”€ EnforceCore (policy enforcement + audit trail)

High-Security Production

For production with untrusted agents or regulatory compliance:

gVisor / Firecracker microVM
  โ”œโ”€โ”€ AppArmor / SELinux profile
  โ”œโ”€โ”€ seccomp-bpf (minimal syscall whitelist)
  โ”œโ”€โ”€ Network policy (Kubernetes NetworkPolicy / Calico)
  โ”œโ”€โ”€ Dropped all capabilities except CAP_NET_BIND_SERVICE
  โ””โ”€โ”€ Container (Docker)
      โ””โ”€โ”€ Python process
          โ”œโ”€โ”€ EnforceCore (policy enforcement + audit trail)
          โ””โ”€โ”€ NeMo Guardrails / LlamaGuard (prompt safety)

Example Docker Configuration

FROM python:3.12-slim

# Drop all capabilities, add only what's needed
# (handled at runtime via docker run --cap-drop=ALL)

# Read-only root filesystem
# (handled at runtime via docker run --read-only)

# Install EnforceCore
RUN pip install enforcecore

# Non-root user
RUN useradd -m agent
USER agent

COPY policy.yaml /app/policy.yaml
COPY agent.py /app/agent.py

CMD ["python", "/app/agent.py"]
docker run \
  --cap-drop=ALL \
  --read-only \
  --tmpfs /tmp:noexec,nosuid,size=64m \
  --security-opt=no-new-privileges \
  --security-opt seccomp=enforcecore-seccomp.json \
  --network=restricted \
  my-agent:latest

Gap Analysis: What Falls Between Layers

Even with all five layers active, some threats are difficult to catch:

1. Side-Channel Exfiltration

Threat: Agent encodes data in timing patterns, error messages, or resource usage instead of direct output.

Gap: EnforceCore inspects tool arguments and return values, not timing. OS-level tools don't understand agent semantics.

Mitigation: Anomaly detection integration point (EnforceCore provides hooks for custom detectors). Rate limiting reduces bandwidth of timing channels.

2. Semantic Evasion

Threat: Agent rephrases a blocked action in terms the policy doesn't recognize (e.g., using update_file instead of write_file when only write_file is denied).

Gap: Policy must enumerate all tool names. Semantic similarity checking is not deterministic.

Mitigation: Default-deny policy (only explicitly allowed tools can execute). Tool-name normalization. Deep inspection of tool arguments.

3. Transitive Dependencies

Threat: An allowed tool internally calls a dangerous operation (e.g., search_web internally makes HTTP requests to arbitrary URLs).

Gap: EnforceCore enforces at the tool-call boundary. It cannot see what happens inside a tool's implementation.

Mitigation: Network-level enforcement (firewall, seccomp). Tool implementation audits. Wrapping tools with EnforceCore-enforced sub-calls.

4. Model-Level Manipulation

Threat: Adversarial prompt causes the LLM to produce subtly harmful outputs that don't trigger any tool call (e.g., biased medical advice).

Gap: EnforceCore only enforces tool calls. It does not evaluate LLM output quality or correctness.

Mitigation: Prompt-layer defenses (LlamaGuard, NeMo Guardrails). Human-in-the-loop for high-stakes outputs.


Architecture Diagram: Full Stack

graph LR
    User["๐Ÿ‘ค User"] --> Prompt["๐Ÿ’ฌ Prompt Filter<br/>(NeMo / LlamaGuard)"]
    Prompt --> LLM["๐Ÿค– LLM"]
    LLM --> Agent["๐Ÿค– Agent"]
    Agent --> EC["โš™๏ธ EnforceCore<br/>Policy ยท PII ยท Audit"]
    EC -->|"allowed"| Tools["๐Ÿ”ง Tools"]
    EC -->|"blocked"| Denied["๐Ÿšซ Denied"]
    Tools --> Container["๐Ÿ“ฆ Container<br/>seccomp ยท cgroups"]
    Container --> OS["๐Ÿง OS Kernel<br/>SELinux ยท AppArmor"]
    OS --> HW["๐Ÿ”’ Hardware<br/>TPM ยท SGX"]

    style EC fill:#2d7d46,stroke:#1a5c30,color:#fff

Summary

Principle Implementation
No single point of failure Five independent enforcement layers
Least privilege Capabilities + default-deny policy
Defense-in-depth Kernel โ†’ container โ†’ runtime โ†’ prompt
Tamper evidence Merkle-chained audit trail (EnforceCore)
Fail-closed Denied by default at every layer

EnforceCore is one layer in a defense-in-depth stack. It is the layer that understands agent semantics โ€” tool calls, PII, cost budgets, and content rules. It is not a replacement for OS-level security, container isolation, or prompt-level content filters. Use all of them.

See also: