Security Architecture
How security controls are layered across processes, data stores, containers, and the network, and how each layer fails.
AgentShield's security architecture is a set of independent layers. Each layer assumes the others may fail and is designed to fail closed on its own.
Layer 1: Identity and transport
- Agents sign each request with Ed25519 over the raw body. See Request integrity.
- Humans use 12-hour bearer sessions stored as SHA-256 hashes, behind a dashboard that keeps the token in an
HttpOnly,SameSite=Strictcookie. - Service to service: the gateway authenticates to the analyzer with a shared token (required in production) and requires HTTPS for a non-loopback analyzer. The relay requires
tls://NATS and TLS object storage for non-loopback endpoints in production. - Separation of credentials: agent signatures are refused on the control plane; bearer sessions are refused on the gateway.
Layer 2: Authorization
- A deterministic evaluator linked into the gateway: deny precedence, default deny, exact resource rules.
- Body claims about organization, identity, or approval are never authority.
- Role guards on every control plane route; the organization comes from the session's membership.
Layer 3: Execution control
- Only registered adapters run, by tool name and operation.
- Arguments are bound by canonical hash; the adapter validates before anything is claimed.
- Execution is claimed in the database before dispatch and never repeated.
- Deadlines, response caps, and circuit breakers bound each run.
Layer 4: Egress control
- Host allow-list in the gateway's tools file.
- Address checks on the resolved IP immediately before connecting.
- No redirects, no proxies, injected credentials, filtered response headers.
- On Kubernetes, the gateway's egress policy excludes private and link-local ranges as a second, independent check.
Layer 5: Data protection
| Control | Implementation |
|---|---|
| Redaction | Credential-like keys replaced with [REDACTED] before storage or logging |
| No raw arguments | Only redacted canonical JSON and its hash |
| Hashed secrets | Argon2id passwords; SHA-256 session and invitation tokens |
| No private keys | No column for agent private key material |
| Tenant isolation | Composite foreign keys; RLS with app.organization_id for agentshield_app |
| Append-only | Triggers on events, chain, policy versions, decisions |
Layer 6: Detection and evidence
- Behavioral incidents for oversized arguments and deny bursts.
- Advisory content analysis for prompt injection and secrets.
- Hash-chained audit events, exported heads, and hash-verified evidence bundles.
Layer 7: Platform hardening
| Environment | Controls |
|---|---|
| Containers | Non-root users, read-only root filesystems, no-new-privileges, all capabilities dropped, digest-pinned bases, distroless Go images |
| Compose | Every published port bound to 127.0.0.1; metrics ports not published |
| Kubernetes | Restricted Pod Security Standard; no service account tokens; default-deny NetworkPolicy in both directions; analyzer isolated to the gateway |
| Supply chain | Release images signed with cosign keyless signing bound to the release workflow; SBOM and provenance attached; third-party actions pinned to commits |
HTTP hardening
Both the gateway and the control plane set X-Content-Type-Options: nosniff, X-Frame-Options: DENY, Referrer-Policy: no-referrer, and Cache-Control: no-store on every response. Error messages never include stack traces, SQL, or secret values. The gateway sets read, write, and header timeouts and a 1 MiB header limit.
Failure modes
| Failure | Behavior |
|---|---|
| PostgreSQL unavailable | Gateway and control plane readiness 503; no decisions; no allow |
| Redis unavailable | Gateway readiness 503; authentication and budgets fail with 500 |
| Policy document invalid | Deny with policy evaluation failed |
| Analyzer unavailable | analysis: unavailable; the call completes |
| Relay stopped | Outbox grows; readiness reports backlog; no events lost |
| Adapter failing | Circuit opens after five failures; executions fail closed |
| Crash during execution | Execution stays claimed; retry refused |
Implementation references
Was this page helpful?
Threat Model
The assets AgentShield protects, the adversaries it considers, the threats it mitigates, and the assumptions it relies on.
Authentication and Authorization
A security analysis of how AgentShield separates identity from authority for agents and humans, and the attacks each design choice closes.