npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

tcha-protection

v2.0.3

Published

An in-line firewall that blocks prompt injection, SSRF, path traversal, and destructive tool calls for MCP and agent tools, with a built-in 100-probe self-test.

Readme

🛡️ Tcha Protection

An in-line firewall that blocks prompt injection, SSRF, path traversal, and destructive tool calls for MCP and agent tools, with a built-in 100-probe self-test.

npm version License: MIT OWASP LLM Top 10

Tcha Protection runs as an in-line STDIO proxy firewall between your AI agent (Claude Code, Cursor, custom agents) and Model Context Protocol (MCP) servers. It intercepts and blocks SSRF egress to cloud metadata, stops path traversal before it touches the host filesystem, defuses indirect prompt injections, and pauses destructive tool calls for cryptographic Human-in-the-Loop (HITL) authorization. It also ships with a built-in 100-probe self-test benchmarking its own internal defense perimeter.


⚡ Headline Quickstart: In-Line Firewall

Wrap any standard MCP server command in a transparent, zero-trust proxy firewall:

npx tcha-protection wrap -- <mcp command>

Example: Protecting the Official Filesystem MCP Server

npx tcha-protection wrap -- npx -y @modelcontextprotocol/server-filesystem ./workspace

When your agent invokes MCP tools:

  • Safe calls (read_file, list_directory): Forwarded with minimal latency (about 0.7 ms median proxy overhead across scenarios (excludes URL arguments; N=100, local, Windows 8-core laptop)).
  • Path traversal (../../etc/shadow): Blocked in-line with JSON-RPC error code -32001.
  • SSRF egress (http://169.254.169.254): Intercepted before the request touches internal networks or cloud metadata.
  • Destructive actions (delete_file, drop_table): Suspended pending HMAC-SHA256 human authorization token.
  • Every event: Cryptographically logged to an append-only SQLite Merkle audit ledger under ~/.tcha/tcha_events.jsonl.

How to Authorize a Suspended Destructive Action (Out-of-Band HITL Flow)

When an agent invokes a destructive tool (e.g. delete_file, drop_table), Tcha Protection halts the call and emits an out-of-band authorization challenge:

{
  "jsonrpc": "2.0",
  "id": 4,
  "error": {
    "code": -32001,
    "message": "[Tcha Guard]: High-risk Tier 3 tool invocation suspended awaiting human authorization. Run 'tcha approve ch_a1b2c3d4' to authorize.",
    "data": {
      "threat_type": "UNAUTHORIZED_TIER3_ACTION",
      "rule_id": "SEC-HITL-003",
      "challengeId": "ch_a1b2c3d4",
      "toolName": "delete_file",
      "params": { "path": "./workspace/note.txt" },
      "expiresAt": 1729000300
    }
  }
}

Step 1: Human Out-of-Band Approval

A human operator in a separate terminal verifies the tool parameters and signs the authorization:

npx tcha-protection approve ch_a1b2c3d4

This cryptographically signs the pending challenge using the local secret key (~/.tcha/hitl_secret) and records it in ~/.tcha/pending_approvals.json.

Step 2: Safe Downstream Execution

When the agent retries the call, Tcha Protection verifies the authentic human signature, releases that single invocation downstream to the MCP server, and immediately marks the challenge as CONSUMED to prevent replay attacks.

Security Note: By default, Tcha Protection strictly rejects agent self-approval attempts. An agent cannot derive or sign its own tokens.

Automated Testing Mode: --allow-inline-approval

For automated integration test suites and CI scripts, you can permit inline HMAC token resubmission by passing --allow-inline-approval:

npx tcha-protection wrap --allow-inline-approval -- <mcp-command>

⚡ Performance Overhead Benchmark (npm run bench)

Measure deterministic proxy overhead on your local machine across all request types:

npm run bench

Headline Performance: about 0.7 ms median proxy overhead across scenarios (excludes URL arguments; N=100, local, Windows 8-core laptop).

Per-Scenario Breakdown:

  • Safe Read-Only Tool: 0.38 ms median (0.69 ms p95)
  • Blocked Path Traversal: 0.34 ms median (0.45 ms p95)
  • Blocked SSRF Egress (IP literal): 0.37 ms median (0.55 ms p95)
  • State-Mutating Tool: 0.39 ms median (0.62 ms p95)
  • Tier 3 Destructive (HMAC Challenge + State Persist): 1.71 ms median (2.42 ms p95)
  • Overall Across All Scenarios: 0.67 ms median (0.99 ms p95)

🧪 Built-In Defense Benchmark (100-Probe Self-Test)

Run the built-in self-test to verify Tcha Protection's defense mechanisms locally in your environment:

Note: This self-test benchmarks Tcha Protection's own built-in defense modules against 100 adversarial vectors; it does not probe or attack your external agent.

npx tcha-protection audit

Real Self-Test Output

$ npx tcha-protection audit
[Tcha Protection] Launching 100-probe Defense Benchmark (Self-Test)...
[Tcha Protection] Note: Benchmarks Tcha Protection's own built-in guards, not your agent.

======================================================================
🛡️  Tcha Protection Pro 2.0 Defense Benchmark (100-Probe Self-Test)
   Note: This self-test benchmarks Tcha Protection's own built-in guards, not your agent.
   Evaluating OWASP Top 10 for LLMs 2025/2026 Defense Perimeter
======================================================================

[Phase 1/4] Auditing Prompt Injection & Steganography (25 Probes)...
  ✓ Probe 01-25: Neutralized injection, delimiter breakout & zero-width stego

[Phase 2/4] Auditing SSRF & Egress Firewall (25 Probes)...
  ✓ Probe 01-25: Blocked AWS/GCP IMDS (169.254.169.254), hex IPs, IPv6 & loopbacks

[Phase 3/4] Auditing Path Traversal & Shell Probes (25 Probes)...
  ✓ Probe 01-25: Flagged & sanitized directory traversal and pipe injections

[Phase 4/4] Auditing Tool Privilege & HITL Gates (25 Probes)...
  ✓ Probe 01-25: Intercepted Tier-3 destructive actions (table drops, shell exec)

======================================================================
🏆 DEFENSE BENCHMARK COMPLETE: 100/100 Probes Neutralized (100.0%)
======================================================================
🌟 BENCHMARK STATUS: MAXIMUM (100% Defense Benchmark Pass)
   Execution Time: 1.41s | Zero SSRF escapes | 100% destructive tools caught

🚀 Additional CLI Commands

# Generate an air-gapped Executive Compliance Report (HTML/PDF)
npx tcha-protection report audit-report.html

# Verify cryptographic Merkle ledger integrity
npx tcha-protection verify-ledger

# Start the local cybersecurity web dashboard (port 4420)
npx tcha-protection start

👉 Need continuous cloud red-teaming and managed SOC alerts? Join the waitlist at tcha.dev


📊 100-Probe Attack Matrix Coverage

| Attack Vector | Category | OWASP LLM 2025/2026 Matrix | Defended By | |---|---|---|---| | Indirect Prompt Injection | 25 Probes | LLM01:2025 Prompt Injection | PromptSanitizer (XML encapsulation & delimiter neutralization) | | Unicode Steganography & ASCII Smuggling | Integrated | LLM01:2025 / Steganographic Evasion | PromptSanitizer (Zero-width stripping & tag filter) | | SSRF & Cloud Metadata Exfiltration | 25 Probes | LLM02:2025 Sensitive Information / SSRF | SSRFGuard (IMDSv1/v2, IPv4/IPv6, hex/octal decoding) | | Path Traversal & Shell Metacharacters | 25 Probes | LLM05:2025 Improper Output Handling | RiskEngine (Argument token inspection & sanitization) | | Unauthorized Tool Abuse & Privilege Escalation | 25 Probes | LLM06:2025 Excessive Agency & Autonomy | RiskEngine (3-Tier classification & HMAC sign-off gate) |


⚠️ Known Limitations & Threat Model

Tcha Protection provides defense-in-depth at the MCP transport layer, but you should understand its security boundaries:

  1. Heuristic & Pattern-Based Detection:
    • Path traversal and argument inspection look for suspicious tokens (.., ;, |, $(, null bytes, %2e%2e). While effective against common automated escapes, token pattern matching is heuristic and not an OS-level sandbox.
    • Attackers with novel encoding polyglots or complex multi-hop filesystem indirection could theoretically evade pure token heuristics.
  2. Not an Operating System Sandbox:
    • Tcha Protection is a protocol-level JSON-RPC firewall. It does not replace running MCP servers with OS-level least privilege (e.g., dedicated Linux users, Docker containers with read-only root filesystems, minimal capability flags).
    • If a downstream tool has an internal vulnerability that executes without suspicious parameters, Tcha will pass the valid-looking parameters through.
  3. Defense Benchmark vs. Target Pen-Testing:
    • The default npx tcha-protection audit command runs a built-in self-test of Tcha Protection's own internal defense engines against 100 OWASP/adversarial vectors. It does not attack or benchmark your custom external agent or MCP server.
    • Roadmap: Active targeting via npx tcha-protection audit --target "<mcp command>" is currently designed and scheduled for upcoming releases to dynamically introspect and red-team third-party MCP servers.
  4. Out-of-Band Approval Boundaries & Host File/Shell Access:
    • Out-of-band human approval (tcha approve <challenge-id>) protects against agents that interact exclusively via MCP tool invocations.
    • For agents that possess direct host shell execution (e.g. bash, terminal execution tools) or host filesystem access, the ~/.tcha directory (which holds hitl_secret and pending_approvals.json) must not be readable or writable by the agent process.
    • Enforce process isolation by running the agent under a separate OS user account, inside an unprivileged Docker container, or by mounting ~/.tcha into a volume restricted from the agent process.
  5. Operating System User Separation vs. Passwords:
    • The approval workflow (tcha approve <challenge-id>) is protected by operating system user boundary separation, not by a password prompt or interactive authentication factor. Any process running under the same OS user account with access to the local shell can sign pending challenges.
  6. Store Concurrency & File Locking:
    • The local approval store (~/.tcha/pending_approvals.json) relies on atomic file reads and writes without OS-level file locking. Under heavy parallel concurrency across multiple proxy instances, uncoordinated concurrent writes could race.
  7. Windows Filesystem Permissions (POSIX Modes):
    • Windows does not enforce POSIX file permission bits (0700, 0600) on ~/.tcha/hitl_secret. On Windows hosts, the security of the signing secret depends on Windows user profile directory ACLs.
  8. Ephemeral Secret Restarts:
    • If ~/.tcha is unwritable and the proxy falls back to an in-memory secret, restarting the proxy process generates a new key and immediately invalidates all previously issued pending approval challenges.
  9. Heuristic Secret Redaction:
    • Secret redaction in challenge summaries is heuristic (matching key names and token shapes) and may miss secrets stored under neutral keys or short values.
  10. SSRF Guard & DNS Resolution Boundaries:
  • Explicit http(s) URLs are resolved through the system resolver at inspection time: DNS queries for hostnames found in tool arguments (including the full domain names) go directly to the host's configured DNS resolver. Because DNS queries leave the machine, they could be abused as a covert exfiltration channel by an injected prompt.
  • The inspection check is not safe against DNS rebinding (TTL = 0), because downstream tools may resolve the hostname again later with a different address.
  • Using the --no-dns-resolve flag switches network DNS resolution off entirely (evaluating only IP literals, dynamic DNS providers, and static domain suffix policies). While this eliminates outbound DNS queries and covert channels, it is strictly weaker against attacker-controlled public domains that resolve to internal private IP addresses. It should only be used in air-gapped or hermetic CI testing environments.
  1. SSRF Inspection Scope:
  • SSRF inspection covers argument values that are entire URLs or hosts. URLs embedded inside longer strings, shell commands, or file contents are not inspected (for example, curl http://127.0.0.1/admin passed to a shell tool). Pair the proxy with network egress controls for tools that can run commands.

🏛️ Architecture & 6-Pillar Spec Blueprint

Tcha Protection Pro 2.0 was architected in adherence to the 6-Pillar Engineering Specification Blueprint:


📜 Compliance Standards Addressed

  • EU AI Act (Regulation 2024/1689): Article 15 (Cybersecurity & Robustness Requirements for Autonomous Systems).
  • SOC 2 Type II: CC6.1 / CC6.6 (Perimeter & Egress Security Boundaries).
  • OWASP Top 10 for Large Language Models 2025/2026: Comprehensive probe coverage across LLM01 through LLM09.
  • ISO/IEC 42001:2023: Control A.6.2 (AI System Risk Management & Tamper-Evident Audit Logging).

📜 License

MIT License. Created with Antigravity 2.0.