Zero-Trust Sandbox Auditor 推出 AI Agent 命令執行前審核工具
Stop Letting AI Agents Run Commands Blindly: Meet Zero-Trust Sandbox Auditor
作者 Malik Taimoor Awan 推出開源工具 Zero-Trust Sandbox Auditor(ztsa),在目標命令執行前檢查沙盒環境及依賴項是否符合信任策略。
Stop Letting AI Agents Run Commands Blindly: Meet Zero-Trust Sandbox Auditor
Every developer I know is experimenting with autonomous AI coding agents—Claude Code, Cursor, Windsurf, Devin, GitHub Copilot Workspace, or custom agentic loops. We grant them terminal access, watch them plan tasks, write code, resolve issues, and install dependencies.
It feels like magic. Until you ask yourself the uncomfortable question:
What happens when an AI agent runs
npm installorcargo buildon a repository with an obfuscated postinstall hook or a malicious build script?
Or worse:
- What if the agent has access to your unencrypted
~/.ssh/id_rsaor~/.aws/credentials? - What if the container it runs inside has
/var/run/docker.sockmounted, allowing instant root escape to the host? - What if an install script opens a background reverse shell listening on
0.0.0.0?
Most developers assume: "It is running in Docker, so I am safe."
That assumption is often dangerously wrong.
A sandbox is only as secure as its actual configuration. If sensitive directories are mounted, capabilities like CAP_SYS_ADMIN are retained, seccomp filters are disabled, or npm lifecycle scripts run unrestricted network requests, your sandbox is security theater.
That is why I created Zero-Trust Sandbox Auditor (ztsa).
🎯 The Core Philosophy: Never Convert Uncertainty into Permission
Before executing untrusted code or letting an autonomous agent install third-party packages, we need a deterministic preflight gate that answers one specific question:
Does this execution environment and dependency manifest currently satisfy the isolation and integrity indicators required for this trust level?
Notice what that means:
- A skip is not a pass. If an operating system indicator cannot be checked on a given platform, it is marked as skipped—never converted to an approval.
-
Deterministic execution gating. If the policy fails, the target command is never started (Exit code
3). -
Zero runtime dependencies. Built with 100% native Node.js standard library (
node:fs,node:child_process,node:crypto). No untrusted transitive dependencies auditing your untrusted dependencies!
📐 Architecture & Workflow
Here is how sandbox-audit sits between the agent and the operating system:
┌────────────────────────────────────────┐
│ Autonomous Agent / Developer / CI │
└───────────────────┬────────────────────┘
│
▼
┌──────────────────────────────────────────┐
│ sandbox-audit (ztsa) │
│ Preflight Execution & Hook Auditor │
└────────────────────┬─────────────────────┘
│
┌──────────────────────────┴──────────────────────────┐
▼ ▼
┌───────────────────────────────┐ ┌───────────────────────────────────┐
│ Environment Probe │ │ Dependency Hook Analyzer │
│ • Linux /proc, /sys status │ │ • npm scripts & local wrappers │
│ • Seccomp, NoNewPrivs, Caps │ │ • Cargo build.rs AST & APIs │
│ • Exposed sockets & listeners │ │ • Registry lockfile validation │
│ • Sensitive credential mounts │ │ • Cargo source/patch replacements │
└───────────────┬───────────────┘ └─────────────────┬─────────────────┘
│ │
└──────────────────────┬────────────────────────┘
│
▼
┌───────────────────────────────┐
│ Policy Evaluation Engine │
│ (repo | dependency | untrusted)
└───────────────┬───────────────┘
│
┌──────────────────┴──────────────────┐
[BLOCK / FAILS POLICY] [ALLOW / PASSES POLICY]
▼ ▼
┌───────────────────────────┐ ┌───────────────────────────┐
│ Write SECURITY_REPORT.md │ │ Emit Self-Attestation │
│ Abort execution │ │ (.sandbox/attestation) │
│ Exit code 3 │ │ Run Target Command │
└───────────────────────────┘ └───────────────────────────┘
🔍 The 4 Defense Domains (38 Rules)
zero-trust-sandbox-auditor enforces 38 discrete, auditable rules grouped into four primary categories:
1. 🌐 Environment Integrity (ENV001 - ENV009)
-
ENV001: Running asroot(uid 0). -
ENV002: Isolation could not be confirmed (no container, VM, or user-namespace marker). -
ENV003: Seccomp filter disabled (mode 0 instead of mode 2). -
ENV004:NoNewPrivsflag missing. -
ENV005: Dangerous Linux capabilities present (CAP_SYS_ADMIN,CAP_SYS_PTRACE,CAP_NET_ADMIN). -
ENV006/ENV007: Code-injection environment variables detected (LD_PRELOAD,NODE_OPTIONS,PYTHONPATH).
2. 🗄️ Filesystem & Credential Leakage (FS001 - FS008)
-
FS001: Container daemon socket mounted (docker.sock,containerd.sock,podman.sock). -
FS002/FS003: Host credential paths readable or writable (~/.ssh,~/.aws,~/.kube,~/.gnupg). -
FS004: Sensitive system directories writable (/usr,/etc,/boot). -
FS006: Project.npmrcexposing unmasked authentication tokens. -
FS007: Secret-like environment variables leaked to child processes.
3. 🔌 Network Exposure (NET001 - NET004)
-
NET001: Active TCP listeners bound to0.0.0.0or::(accidental exposed backdoors). -
NET004:DOCKER_HOSTconfigured pointing outside the local sandbox.
4. 📦 Supply-Chain & Dependency Build Hooks (DEP000 - DEP016)
-
DEP001: Missing integrity lockfiles (package-lock.json,Cargo.lock,pnpm-lock.yaml). -
DEP003: Untrusted lifecycle scripts (preinstall,postinstall,prepare). -
DEP004/DEP005: Piped shell installers detected inside manifest scripts (e.g.,curl | sh,wget). -
DEP006: Unpinned Git commit references or local path dependencies. -
DEP008/DEP009: Cargobuild.rsanalyzing invocations of network, subprocess execution, or directory traversal APIs.
🚦 Three Dynamic Trust Profiles
Not every scenario requires the same paranoia level. ztsa provides three calibrated operational profiles:
| Profile | Target Use Case | Behavior |
|---|---|---|
repo |
Auditing your own team's trusted repository. | Permissive of standard dev files; alerts on dangerous caps, root privileges, and uncommitted git hooks. |
dependency |
Preflight before running npm install or cargo build. |
Blocks unpinned registries, lifecycle scripts, and active network calls in build hooks. |
untrusted |
Autonomous AI agents running code from pull requests, issues, or public repos. | Strict zero-trust. Demands confirmed isolation, drops permissions, blocks write mounts and open sockets. |
💻 How to Use It in Practice
1. Instant Verification via GitHub / npx
You can run sandbox-audit right now without installing anything permanently:
# Audit the current workspace with dependency-level scrutiny
npx github:6t9xstar/zero-trust-sandbox-auditor verify --trust dependency
# Run strict zero-trust audit for an autonomous agent
npx github:6t9xstar/zero-trust-sandbox-auditor verify --trust untrusted --format json
Or clone the repository:
git clone https://github.com/6t9xstar/zero-trust-sandbox-auditor.git
cd zero-trust-sandbox-auditor
node bin/sandbox-audit.js verify --trust untrusted
2. Guarded Execution (exec)
This is the superpower for AI coding agents. Instead of running:
npm ci --ignore-scripts
The agent or wrapper script executes:
sandbox-audit exec --trust dependency -- npm ci --ignore-scripts
If any finding meets or breaches the configured policy threshold:
-
ztsaimmediately aborts. - Outputs a detailed
SECURITY_REPORT.md. - Exits with Code
3(POLICY BLOCK). - The target command is NEVER executed.
🛡️ Defense-in-Depth: The Two Halves of Agent Security
To build a truly secure AI coding environment, you need two layers working in tandem:
- Preflight Verification Gate (Zero-Trust Sandbox Auditor): Proves that the environment is unprivileged, credentials are safe, and build hooks are clean before commands execute.
- Runtime Isolation Jail (ShadowCLI): Enforces kernel-level unprivileged isolation (Linux Landlock, seccomp-bpf, OverlayFS) while commands are running.
When you pair preflight static verification with runtime sandboxing, you finally have true zero-trust execution for autonomous agents.
🌟 Take It for a Spin & Contribute!
zero-trust-sandbox-auditor is 100% open-source under the MIT license.
- GitHub Repository: https://github.com/6t9xstar/zero-trust-sandbox-auditor
- Author Profile: https://github.com/6t9xstar
If you are building AI agents, configuring CI/CD pipelines, or worried about supply-chain attacks in modern developer workflows:
👉 Please head over to GitHub and star the repository ⭐!
Your stars and feedback help bring awareness to safe, responsible AI development.
💬 Discussion
How do you currently verify that an AI coding agent or PR build hook isn't exfiltrating credentials or breaking out of its container? Let's discuss in the comments below!
來源:DEV Community · dev.to