{"slug": "show-hn-agentshield-zero-dep-secret-redactor-and-shell-firewall-for-claude", "title": "Show HN: AgentShield Zero-dep secret redactor and shell firewall for Claude", "summary": "RitualDev-Lab released AgentShield, a zero-runtime-dependency tool that intercepts shell commands and stdout/stderr from autonomous coding agents such as Claude Code, Cursor and Windsurf to block reads of `.env` files, `printenv` environment dumps and other credential leaks before they reach third-party model APIs or git history. AgentShield reports under 20 µs P99 redaction across 10,000-call benchmarks at more than 149,000 ops/sec, and ships a command firewall that catches obfuscated variants like `cat .e\"\"nv`, `/proc/self/environ` and inline `node`/`python` env dumps, plus OS sandbox preflight for macOS Seatbelt, Linux bwrap/Landlock and Windows AppContainer. The project's THREAT_MODEL.md states that userland command inspection is defense-in-depth against accidental exfiltration and common script bypasses, not an OS kernel security boundary.", "body_md": "**Stop Claude Code, Cursor, Windsurf, and autonomous coding agents from leaking `.env` secrets, SSH keys, or running destructive shell commands.**\n\nZero runtime dependencies. 100% local & air-gapped by default. `<20 µs` P99 redaction across 10,000-call benchmarks (`149k+ ops/sec`).\n\n```\nnpx @ritualdev-lab/agentshield demo\nbash\n$ npx @ritualdev-lab/agentshield exec \"cat .env && printenv\"\n[AgentShield] BLOCKED: Direct credential file read & environment dump (.env / printenv)\n\n$ node print-config.js | npx @ritualdev-lab/agentshield stream\n{\"db\":\"[AGENT_SHIELD:DATABASE_URL:9f3a12]\",\"token\":\"[AGENT_SHIELD:GITHUB_TOKEN:4c8e19]\"}\n```\n\nWant to record a fresh 15-second terminal GIF? Run [`vhs assets/demo.tape`](https://github.com/RitualDev-Lab/AgentShield/blob/main/assets/demo.tape) with [Charm VHS](https://github.com/charmbracelet/vhs).\n\nAutonomous coding agents have direct access to your shell, filesystem, and git repo. Even well-behaved agents routinely run `cat .env`, `printenv`, `node -e 'console.log(process.env)'`, or commit live test keys into PRs—leaking raw credentials into third-party model APIs and git history.\n\nAgentShield intercepts commands and stdout/stderr **before** credentials leave your machine:\n\n- **Obfuscation-resistant command firewall** : Catches`cat .e\"\"nv` ,`cat .e?v` ,`/proc/self/environ` ,`base64` /`xxd` ,`tar` /`cp` , and inline`node` /`python` env dumps.\n- **Boundary-safe streaming redactor** : Catches secrets split across arbitrary 1-byte TCP/stdio chunks and multiline PEM blocks (0 runtime dependencies, linear-time regex + Shannon entropy).\n- **OS sandbox preflight & profiles** : Generates and verifies macOS Seatbelt (`sandbox-exec` ), Linux`bwrap` /Landlock, and Windows AppContainer isolation via`agentshield doctor` .\n- **Unified 3-layer stack** : Boot AgentShield +[DBShield](https://github.com/RitualDev-Lab/DBShield) +[SkillPrism](https://github.com/RitualDev-Lab/SkillPrism) from a single declarative[`ritual.policy.yaml`](https://github.com/RitualDev-Lab/AgentShield/blob/main/examples/ritual.policy.yaml) via`agentshield up` .\n\nThink you can bypass our `.env` / `/proc/self/environ` blocker or split a secret across stream chunks without triggering redaction?\n\n```\nnpx @ritualdev-lab/agentshield bounty-verify \"your-payload-here\"\n```\n\nIf you find a bypass, open an issue with your repro—every confirmed bypass gets a regression test and credit in the repo. Check [`THREAT_MODEL.md`](https://github.com/RitualDev-Lab/AgentShield/blob/main/THREAT_MODEL.md) for exact scope and honest OS isolation limits.\n\n[Quick Start](#-instant-30-second-setup) · [Full Guide](https://github.com/RitualDev-Lab/AgentShield/blob/main/GUIDE.md) · [Threat Model](https://github.com/RitualDev-Lab/AgentShield/blob/main/THREAT_MODEL.md) · [Examples (Claude Code, LangGraph, E2B/Daytona)](https://github.com/RitualDev-Lab/AgentShield/blob/main/examples) · [GitHub Action](#-3-cicd-security-gate--github-action)\n\n```\n# 1. Diagnose your OS sandbox (Seatbelt / bwrap / Landlock / AppContainer)\nnpx @ritualdev-lab/agentshield doctor\n\n# 2. Install a git pre-commit secret leak gate\nnpx @ritualdev-lab/agentshield hook install\n\n# 3. Generate Claude Code PreToolUse or Cursor hooks\nnpx @ritualdev-lab/agentshield init-claude\nnpx @ritualdev-lab/agentshield init-cursor\n\n# 4. Wrap any agent shell command safely\nnpx @ritualdev-lab/agentshield exec \"cat .env\"\n```\n\nIntercept and sandbox agent terminal execution. If an agent tries to read `.env`, dump shell variables (` printenv`), or send keys to outbound endpoints, AgentShield blocks it on the fly:\n\n```\nnpx @ritualdev-lab/agentshield exec \"cat .env\"\n# 🚨 [AgentShield Sandbox Block] Blocked attempt to read raw .env or private credential file.\n# Protected credentials from entering agent LLM context window!\n```\n\nImportant\n\n**Defense-in-Depth vs OS Security Boundary**:\nUserland command inspection (AST parsing and regex heuristics) is **defense-in-depth** designed to prevent accidental exfiltration and common script bypasses. It is **not** an OS kernel security boundary. Arbitrary compiled binaries or direct kernel syscalls require true OS-level containerization.\n\n| Platform | Primary Isolation Mechanism | Security Boundary Level | Guarantees & Limitations | \n|---|---|---|---|\n| **macOS** | `macos_sandbox_exec` | **Kernel-Enforced** | System call mediation via Apple Seatbelt; restricts file read/write and networking outside workspace. | \n| **Linux** | `linux_landlock` /`bwrap` | **Defense-in-Depth***(unless containerized)* | Generates Landlock LSM & bubblewrap profiles. Without a container runtime, Node child processes inherit caller privileges. | \n| **Windows** | `windows_appcontainer` | **Defense-in-Depth** | Generates AppContainer / Low-Integrity profile templates. Win32 child processes run with normal caller token integrity. | \n| **Fallback** | `process_level_firewall` | **Defense-in-Depth** | AST pattern firewall and real-time streaming redaction. | \n\nBy default, requesting kernel sandboxing on non-macOS hosts logs an isolation warning and runs under the defense-in-depth AST firewall. To **fail-closed** and refuse execution whenever OS-level kernel isolation cannot be guaranteed:\n\n```\n# Refuse execution if the host cannot enforce true OS kernel isolation\nnpx @ritualdev-lab/agentshield exec \"npm test\" --require-isolation\n# 🛑 [AgentShield Isolation Refusal] Execution refused: requireIsolation is enabled, but OS-level kernel isolation is unavailable on host (win32). Refusing to silently downgrade to process-level firewall.\n```\n\nIn the TypeScript SDK:\n\n``` js\nconst result = await interceptor.execute(command, {\n  enableKernelSandbox: true,\n  requireIsolation: true, // Fails closed instead of silently downgrading\n});\n```\n\nCatch leaked credentials before they enter git history. Audits staged diffs automatically:\n\n```\n# Install once in your repo (native git hook)\nnpx @ritualdev-lab/agentshield hook git-install\n\n# Or manually audit staged files\nnpx @ritualdev-lab/agentshield hook check\n```\n\nOr using the standard [pre-commit](https://pre-commit.com/) framework (`.pre-commit-config.yaml`):\n\n```\nrepos:\n  - repo: https://github.com/RitualDev-Lab/AgentShield\n    rev: v0.1.1\n    hooks:\n      - id: agentshield\n      - id: agentshield-audit\n```\n\nBlock pull requests that introduce exposed credentials into your codebase:\n\n```\nname: AgentShield Security Gate\non: [pull_request, push]\n\njobs:\n  secret-audit:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n        with:\n          fetch-depth: 0\n      - uses: RitualDev-Lab/AgentShield@v1\n        with:\n          fail_on_leak: \"true\"\n```\n\nOr run via CLI in any CI container:\n\n```\nnpx @ritualdev-lab/agentshield ci --base origin/main --report security-report.md\n```\n\nAssess files and workspace streams against technical secret-handling controls in standard frameworks (SOC 2, PCI-DSS, HIPAA, ISO 27001):\n\n```\nnpx @ritualdev-lab/agentshield compliance .env\n📋 [SECRET-CONTROL ASSESSMENT] Status: NO_FINDINGS_IN_ASSESSED_CONTROLS (Assessed Controls Score: 100%)\nℹ️  Scope: Technical secret detection, real-time streaming token redaction, and CLI command firewall.\n⚠️  Disclaimer: Notice: This report reflects only the results of automated secret detection across assessed technical controls ('NO_FINDINGS_IN_ASSESSED_CONTROLS'). It does NOT establish overall organizational SOC 2, HIPAA, PCI-DSS, or ISO 27001 compliance. Overall compliance requires an accredited third-party audit firm, administrative governance, physical safeguards, and operational policies.\n\n  Assessed Controls:\n    ✅ [SOC2] CC6.1: Logical Access Controls & Credential Integrity\n    ✅ [SOC2] CC6.6: Boundary Protection & Unauthorized Egress Controls\n    ✅ [PCI_DSS] Req-3.4: Protection of Authentication & Payment Gateway Secrets\n    ✅ [PCI_DSS] Req-8.3: Strong Authentication Credential Management\n    ✅ [HIPAA] §164.312(a)(1): Technical Safeguards - Access Control & Authentication\n    ✅ [ISO27001] A.8.28: Secure Coding & Secret Management\n    ✅ [ISO27001] A.8.24: Use of Cryptography & Key Protection\n\n  Broader Controls (Not Assessed by Secret Scanning):\n    ⏸️  [SOC2] CC1.1: Integrity & Ethical Values (Governance) (NOT ASSESSED)\n    ⏸️  [SOC2] CC5.2: Risk Assessment & Vendor Management (NOT ASSESSED)\n    ⏸️  [PCI_DSS] Req-9.1: Physical Access Restrictions (NOT ASSESSED)\n    ⏸️  [HIPAA] §164.308(a)(1): Administrative Safeguards (NOT ASSESSED)\n    ⏸️  [ISO27001] A.5.1: Policies for Information Security (NOT ASSESSED)\n```\n\nInstead of cleartext `.env` keys, AgentShield provides deterministic, collision-resistant surrogate tokens (`[AGENT_SHIELD:ID:hexHash]`). Agents can safely manipulate configurations and inspect outputs without ever seeing the plaintext secret in prompt history, rehydrating values locally when required.\n\nAgentShield provides 1-command generators for leading AI coding agent environments:\n\nAutomatically intercept agent terminal executions before commands touch your environment:\n\n```\nnpx @ritualdev-lab/agentshield init-claude\n```\n\nGenerates `.claude/settings.json` configured with:\n\n```\n{\n  \"hooks\": {\n    \"PreToolUse\": [\n      {\n        \"matcher\": \"Bash|Terminal\",\n        \"command\": \"npx @ritualdev-lab/agentshield exec --claude-hook\"\n      }\n    ]\n  }\n}\n```\n\n*Note: Claude Code delivers tool call payloads via stdin JSON. AgentShield inspects the payload in real-time and cleanly returns exit code `2` to halt unauthorized commands before execution.*\n\n```\nnpx @ritualdev-lab/agentshield init-cursor\n```\n\nGenerates `.cursor/rules.json` with sensitive path boundaries (`.env*`, `*.pem`, `id_rsa*`) and pre-execution command sandboxing.\n\nPlug [`SKILL.md`](https://github.com/RitualDev-Lab/AgentShield/blob/main/SKILL.md) into workspace agent instructions to enforce zero-leak guarantees natively.\n\nTraditional scanners (`gitleaks`, `trufflehog`) were designed for **post-facto static git repository scanning** (scanning files and commit histories at rest).\n\n**AgentShield** is designed specifically for **Autonomous Agent Runtime Protection** — intercepting shell commands, scrubbing streaming stdio chunk-by-chunk in sub-milliseconds, and sanitizing LLM prompt inputs before transmission.\n\n| Feature / Metric | AgentShield | GitLeaks | TruffleHog | \n|---|---|---|---|\n| **Primary Domain** | **Agent Runtime & Stdio Interception** | Git History Scanner | Git & Filesystem Scanner | \n| **Average Scan Latency** | **< 0.04 ms / scan** | ~ 2 - 5 ms | ~ 10 - 50 ms | \n| **Throughput** | **28,000+ operations/sec** | ~ 5,000 ops/sec | ~ 1,200 ops/sec | \n| **Streaming Stdio Interception** | ✅ **Native (`createRedactingStream`)** | ❌ (Disk / Git diff only) | ❌ (Disk / Git diff only) | \n| **Agent AST Command Sandbox** | ✅ **Native (`exec` / `run`)** | ❌ None | ❌ None | \n| **Deterministic Vault Rehydration** | ✅ **Native (`[AGENT_SHIELD:...]`)** | ❌ None | ❌ None | \n| **MCP Protocol Filter (JSON-RPC)** | ✅ **Native (`mcp-proxy`)** | ❌ None | ❌ None | \n| **Zero Runtime Dependencies** | ✅ **0 deps (Pure Node.js)** | Go binary | Go binary / Python | \n| **Git Pre-Commit & CI Gates** | ✅ Built-in | ✅ Built-in | ✅ Built-in | \n\nAgentShield combines high-performance regular expressions with **Shannon Entropy** to catch both structured keys and arbitrary high-entropy passwords:\n\n- 🤖 **AI Providers** : OpenAI (`sk-proj-*` ), Anthropic Claude (`sk-ant-*` ), Google Gemini (`AIzaSy*` ), Hugging Face (`hf_*` )\n- ☁️ **Cloud Infrastructure** : AWS Access Key ID (`AKIA*` ), AWS Secret Access Keys\n- 💳 **Payments & SaaS** : Stripe Live (`sk_live_*` ), Slack Incoming Webhooks\n- 🐙 **Version Control** : GitHub Personal Access Tokens (`ghp_*` ,`github_pat_*` )\n- 🔐 **Cryptography** : PEM / OpenSSH private key blocks, JSON Web Tokens (JWT)\n- 📊 **Mathematical Entropy** : High-entropy password detection with false-positive filtering\n\nAgentShield provides first-class, idiomatic SDKs across multiple languages:\n\n| Language / Platform | Package / Location | Supported Runtimes & Frameworks | Integration Pattern | \n|---|---|---|---|\n| **Node.js / TypeScript** | `@ritualdev-lab/agentshield` | Node 20+, Cursor, Claude Code, MCP | In-process native TypeScript | \n| **Python** | `agentshield` (`sdks/python` ) | Python 3.9+, LangChain, LangGraph, CrewAI, AutoGen | In-process standalone + Sidecar | \n| **Go** | `sdks/go` | Go 1.21+, `net/http` middleware, Gin, Chi | JSON-RPC 2.0 Stdio Sidecar | \n| **Rust** | `sdks/rust` | Rust 2021 edition | JSON-RPC 2.0 Stdio Sidecar | \n| **Any Language / Shell** | `agentshield sidecar` | Ruby, Elixir, PHP, C++, Bash | Stdio Line-Delimited JSON-RPC 2.0 | \n\nWorks in pure-Python without requiring Node.js, with built-in LangChain/LangGraph callbacks:\n\n``` python\nfrom agentshield import AgentShieldEngine, AgentShieldCallbackHandler\nfrom langchain_openai import ChatOpenAI\n\nshield = AgentShieldEngine()\nredacted = shield.scan_and_redact(\"Query database with sk-proj-placeholder-token\")\nprint(redacted[\"sanitizedText\"])\n# \"Query database with [AGENT_SHIELD:AI:7b3a4f1c]\"\n\n# Attach to LangChain to protect prompt inputs automatically:\nllm = ChatOpenAI(callbacks=[AgentShieldCallbackHandler()])\nimport \"github.com/RitualDev-Lab/agentshield/sdks/go\"\n\nclient, _ := agentshield.NewClient(ctx)\ndefer client.Close()\n\nres, _ := client.ScanAndRedact(ctx, \"Stripe secret sk_live_placeholder_token\")\nfmt.Println(res.SanitizedText)\njs\nuse agentshield::AgentShieldClient;\n\nlet client = AgentShieldClient::new()?;\nlet res = client.scan_and_redact(\"My token is ghp_placeholder_token\")?;\nprintln!(\"Sanitized: {}\", res.sanitized_text);\n```\n\nAny language can interact with AgentShield via line-delimited JSON-RPC 2.0:\n\n```\nnpx @ritualdev-lab/agentshield sidecar\n{\"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"shield.scanAndRedact\", \"params\": {\"text\": \"My API key is sk-proj-placeholder\"}}\n```\n\nResponse:\n\n```\n{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":{\"hasSecrets\":true,\"sanitizedText\":\"My API key is [AGENT_SHIELD:AI:...]\",\"findings\":[...]}}\n```\n\nIntegrate AgentShield directly into your AI workflows, proxy servers, or custom agent frameworks:\n\n``` js\nimport { AgentShieldEngine, AgentCommandSandbox, AgentStdioInterceptor } from \"@ritualdev-lab/agentshield\";\n\nconst shield = new AgentShieldEngine();\n\n// Scan and redact unmasked credentials from LLM prompt inputs\nconst rawPrompt = `Run tests with OPENAI_API_KEY=${mySecretToken}`;\nconst result = shield.scanAndRedact(rawPrompt);\n\nconsole.log(result.hasSecrets); // true\nconsole.log(result.sanitizedText);\n// \"Run tests with OPENAI_API_KEY=[AGENT_SHIELD:OPENAI_API_KEY:c2stcH]\"\n\n// Deterministically rehydrate when receiving LLM response back locally\nconst original = shield.rehydrate(result.sanitizedText);\n```\n\n- **Live Documentation** :[https://agentshield.ritualdev.in/](https://agentshield.ritualdev.in/)\n- **Bug Bounty Program** : Read our[SECURITY.md](https://github.com/RitualDev-Lab/AgentShield/blob/main/SECURITY.md) for rewards ($50 – $500).\n- **Open Governance Charter** : Read our[GOVERNANCE.md](https://github.com/RitualDev-Lab/AgentShield/blob/main/GOVERNANCE.md) for project stewardship.\n- **Grant Applications** : Review our[GRANTS.md](https://github.com/RitualDev-Lab/AgentShield/blob/main/GRANTS.md) dossier for NLnet, OpenSSF & Mozilla.\n- **Contributing** : Check out[CONTRIBUTING.md](https://github.com/RitualDev-Lab/AgentShield/blob/main/CONTRIBUTING.md) to add new secret patterns.\n\nAgentShield is initiated and maintained by the team at [RitualDev Lab](https://github.com/RitualDev-Lab) and protected by the global AI security research community.\n\n|    [<sub>**Divyanshu Jethi**</sub>](https://github.com/divyanshujethi) <sub>🚀 Founder & Lead</sub><sub>🔑 **Direct Access Admin**</sub> |    [<sub>** Sakshi Sharma**</sub>](https://github.com/Sakshisharma1616) <sub>🎨 Core Maintainer & Product</sub><sub>🔑 **Direct Access Admin**</sub> |    [<sub>** RitualDev**</sub>](https://github.com/Ritual-Dev-Git) <sub>⚙️ Core Maintainer & Infra</sub><sub>🔑 **Direct Access Admin**</sub> |    [<sub>** Divyanshu-hub-dotcom**</sub>](https://github.com/Divyanshu-hub-dotcom) <sub>🛠️ Core Member</sub> |    [<sub>** Ayush**</sub>](https://github.com/ayushxx01) <sub>🛡️ Core Maintainer & Triage</sub> | \n\nAgentShield is 100% open-source and Apache-2.0 licensed. Your sponsorship directly funds multi-platform OS sandbox testing rigs (Linux Landlock, macOS Seatbelt, Windows AppContainer), automated security regression suites, and cloud runner hours.\n\n[**⚡ 1-Click Dodo Payments Checkout**](https://checkout.dodopayments.com/buy/pdt_0NpjONGugY5QkrFDUaPva)  •  [**🎁 Interactive Donation Form (USD & INR UPI)**](https://ritualdev.in/donate)  •  **❤️ GitHub Sponsors**\n\n<sub>🔒 *Zero physical shipping required. Powered by Dodo Payments (Merchant of Record) with instant tax invoice and global payment methods (Cards, UPI, Apple Pay).*</sub>\n\n|    [<sub>**ciperx**</sub>](https://github.com/ciperx) <sub>📜 OWASP ATLAS & AEO (PR #8)</sub> |    [<sub>** Voyagerroc-Lab**</sub>](https://github.com/Voyagerroc-Lab) <sub>🔒 Security & Rules Contributor</sub> | \n\n  Huge thanks to all our open-source [Contributors](https://github.com/RitualDev-Lab/AgentShield/graphs/contributors)!\n\n<sub>Maintained with 💜 by</sub>", "url": "https://wpnews.pro/news/show-hn-agentshield-zero-dep-secret-redactor-and-shell-firewall-for-claude", "canonical_source": "https://github.com/RitualDev-Lab/AgentShield", "published_at": "2026-11-18 04:39:11+00:00", "updated_at": "2026-11-18 04:44:52.590533+00:00", "lang": "en", "topics": ["ai-agents", "ai-safety", "ai-tools", "developer-tools"], "entities": ["AgentShield", "RitualDev-Lab", "Claude Code", "Cursor", "Windsurf", "DBShield", "SkillPrism"], "also_reported_by": [], "takeaway": "AgentShield wraps agent shell commands via `agentshield exec` and streams stdout through a redactor that catches secrets split across 1-byte chunks and multiline PEM blocks, blocking `.env` reads and `printenv` dumps at under 20 µs P99 redaction.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/show-hn-agentshield-zero-dep-secret-redactor-and-shell-firewall-for-claude", "markdown": "https://wpnews.pro/news/show-hn-agentshield-zero-dep-secret-redactor-and-shell-firewall-for-claude.md", "text": "https://wpnews.pro/news/show-hn-agentshield-zero-dep-secret-redactor-and-shell-firewall-for-claude.txt", "jsonld": "https://wpnews.pro/news/show-hn-agentshield-zero-dep-secret-redactor-and-shell-firewall-for-claude.jsonld"}}