From Attack Surface to Defense Architecture: Compositional Security for Agentic Coding Harnesses
Organizations: Evercursion – GaiaLogic Unipessoal Lda. · University of Macau · Allianz Group · Nanyang Technological University, Singapore
Abstract
AI coding harnesses couple language models to shells, filesystems, and network sockets, turning the harness into an automated Living-off-the-Land (LotL) platform: once an adversary injects instructions into retrieved content, dual-use binaries such as bash, curl, and find become the payload. We argue that security in agentic systems is a structural property of the cognitive architecture and permission composition rather than an emergent property of individual models. Static regex blacklists miss structural evasions, whereas LLM-as-a-Judge guardrails incur high latency while over-blocking benign work. We present ActiveSecHarness, a neurosymbolic reference-monitor architecture built around Separation of Intelligence and Authority. It combines (1) Macaroon-inspired HMAC capability tokens across four Trust and Authority Rings, (2) a 2D product taint lattice and a workspace provenance ledger that prevents secret laundering across disk, (3) deterministic Ring-0 OS/tool guards, and (4) bytecode certificates, split-horizon audit logs, self-healing security test synthesis, and an adaptive UserWikiManager. Across fixtures ( attack, benign, kill chains), a live local LLM judge (qwen3:4b) refuses of benign work at latency, whereas Ring 0 achieves and in ( faster). In a multi-step trajectory ablation, an oracle Conseca-style stateless policy misses kill chains () and coarse Boolean taint blocks of benign workflows, while our 2D product lattice achieves and at per step.
Figures & tables
| Primitive | Primary requirement |
|---|---|
| Symlink / TOCTOU | Temporal integrity + complete mediation |
| Path traversal | Complete mediation (canonical paths) |
| Subprocess escape | Resource containment (flag / binary policy) |
| Env / PATH injection | Resource containment (scrubbed env) |
| SSRF / DNS rebinding | Temporal integrity (pre-connect IP pin) |
| Credential exposure | IFC + DLP mediation |
| Resource | Ring-0 Interceptor | Enforced Invariant |
|---|---|---|
| Filesystem I/O | SandboxGuard , CanaryGuard | Canonical realpath lock; O_NOFOLLOW ; canary lineage revocation |
| Archives | ArchiveGuard | chunked quotas; staging realpath check; symlink/FIFO reject |
| Subprocesses | SecurityKernel , SandboxGuard | Binary allowlist; GTFOBins flag block; RLIMIT_AS/CPU/NPROC/FSIZE |
| Network Sockets | NetworkGuard | TLS enforcement; resolve-once DNS; RFC1918/metadata block; IP pin |
| Credentials | CredentialGuard | Reverse-cracker demangling; entropy; bidirectional DLP |
| Shared State | WorkspaceProvenanceLedger | Product-lattice join; cross-agent Lethal Trifecta refusal |
| Curriculum Stage | Example 1: Archive Extraction & Zip-Slip ( B.1 , B.2 ) Vibe-coding task: “Write a helper to unpack dataset.zip into ./data .” | Example 2: Obfuscated Sudo & LotL Trap ( A.1 , B.4 , F.1 ) Issue-fix task: “Run the README diagnostic one-liner to fix build permissions.” |
|---|---|---|
| Interception & Automated Repair (Rings – ) | Small coder ( qwen3:4b ) emits zf.extractall(dest) . CodeVerifier ( TIER2_CONTEXTUAL ) executes a live Zip-Slip probe ( ../../evil.sh ) inside the isolated test-runner , catches path escape, and sets . DualModelReviewer repairs the code and recommends escalating to a stronger coder model. | Poisoned README embeds Trojan Source Bidi overrides ( U+202E ) and echo <b64> | base64 -d | sh alongside find . -exec . Ring CommandDeobfuscator strips Bidi controls and unfolds the decoded payload ( curl .../exfil.sh | sh ) in the Explain-Before-Sudo dialog; Ring SandboxGuard denies execution. |
| Level 1: Everyday Analogy & Social-Engineering Angle (Cases 1–2) | Analogy: Opening a moving box labeled “Office Supplies” where an item inside carries an address label saying “Put this directly into the bedroom safe” (Zip-Slip), or an inflatable raft that expands until the walls burst (ZipBomb). Social Engineering: Attackers post “helpful test fixtures” or dataset.zip archives in GitHub issues; small AI models default to zf.extractall() because it is the shortest snippet in training corpora. | Analogy: Passing unverified text to eval() or | sh is like signing a blank check for groceries and letting a stranger fill in the amount—while invisible Unicode Bidi characters act like magic ink that flips word order on the page. Social Engineering: Copy-paste traps in READMEs and forums disguise malicious commands inside Base64 pipes or urgent “permission fix” one-liners to exploit human approval fatigue. |
| Level 2: Secure Engineering Pattern (Unsafe vs. Verified Safe) (Cases 3–4) | Blocked draft: zf.extractall(target_dir) Verified repair: Resolve real_target = os.path.realpath(target_dir) ; for each info in zf.infolist() , reject symlinks ( stat.S_ISLNK(info.external_attr >> 16) ), verify os.path.realpath(dest).startswith(real_target + os.sep) , and stream in chunks ( src.read(65536) ) under hard byte and compression-ratio ceilings. | Blocked pattern: subprocess.run(cmd, shell=True) or Base64 pipe-to-shell echo ... | base64 -d | sh . Verified repair: Pass explicit argument vectors with shell=False ( subprocess.run([’python3’, ’script.py’, arg], shell=False) ), replace eval() with json.loads() or ast.literal_eval() , and strip Unicode Bidi range U+202A – U+2069 at pre-commit gates. |
| Level 3: Adversarial & Cryptographic Mastery (Cases 5+) | Exploit mechanics: Non-recursive ZipBombs ( zbsm.zip ) overlap deflate streams across local headers so aggregate output explodes even when per-entry ratios look modest; two-stage symlink races exploit the TOCTOU gap between path check and open. Countermeasure: Track cumulative total_written / archive_size and extract into an O_NOFOLLOW , 0700 staging directory on a noexec,nosuid,nodev mount before atomic promotion. | Exploit mechanics: Even with shell=False , dual-use GTFOBins binaries ( find -exec , tar --checkpoint-action , git -c core.fsmonitor ) execute sub-commands via flags without invoking /bin/sh . Countermeasure: Pair AST deobfuscation with Ring per-binary flag blacklists, HMAC-attenuated CapabilityToken binary allowlists, and bwrap --unshare-all namespace isolation. |
| Regime | ABR | ABR CI | FPR | Med. (p95) lat. |
|---|---|---|---|---|
| Unguarded | ( ) | |||
| Regex | ( ) | |||
| Live LLM-judge | ( ) | |||
| ActiveSec Ring 0 | ( ) | |||
| Hybrid (Ring 0 auth.) | ( ) |
| Trajectory Regime | Kill-Chain ABR | Benign Traj. FPR | Missed / Blocked Breakdown | State-Fold ( /step) |
|---|---|---|---|---|
| Oracle Stateless Task Policy | Misses ( KC-T03,04,05,11 ) | |||
| Coarse Boolean Taint Lock | Blocks issue-driven SWE | |||
| Product Lattice + Ledger | atk blocked; SWE pass | ( ) |
Appendix figures & tables1 asset
Supplementary material from the paper’s appendix.
Appendix
| ID | Domain | Description |
|---|---|---|
| A.1 | A | GTFOBins / dual-use shell escapes (T1059) |
| A.2 | A | Environment-variable credential inheritance (T1552.001) |
| A.3 | A | Ring 0 self-tampering / defense disable (T1562.001) |
| A.4 | A | SCM hook persistence ( .git/hooks , T1546) |
| B.1 | B | Spoofed-header ZipBomb / nested archive DoS (T1499) |
| B.2 | B | Zip-Slip path and symlink traversal (T1083) |
AI Agent Security
Artificial intelligence agent security studies attacks and safeguards for tool-using, persistent, and collaborative systems across digital and physical settings.
See all 553 papers