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

elizaos-plugin-security-gate

v2.1.2

Published

Deterministic local prompt injection defense, dangerous code pattern detection, and autonomous agent safety guardrails for ElizaOS

Readme

🛡️ elizaos-plugin-security-gate

npm version npm downloads License: MIT

Deterministic local prompt injection defense, dangerous code pattern detection, and autonomous agent safety guardrails for ElizaOS.


🌟 Features

  • 🔒 100% Local-First by Default: Runs entirely within the local node/bun process with zero external network requests and zero data exfiltration.
  • ⚡ Sub-Millisecond Deterministic Latency: Instant regex pattern matching, heuristic command detection, and Unicode normalization (<1ms) for prompts, tool calls, and model inputs.
  • 🛑 Fail-Closed Safety: High-risk injection payloads and dangerous commands are immediately blocked from executing.
  • 🛡️ Comprehensive Threat Interception:
    • Adversarial prompt injections (instruction overrides, system prompt spoofing).
    • Jailbreak personas (DAN mode, Developer Mode overrides).
    • Obfuscation evasions (Zero-width characters \u200B, null-bytes \0).
    • Dangerous code execution patterns (os.system, subprocess, dynamic eval, rm -rf).
    • Accidental credential disclosures (private keys, raw hex seed material).
  • 🌐 Optional Opt-In Remote Oracle: Connect to custom micro-oracle endpoints by explicitly setting SECURITY_GATE_URL (enforces 3s timeout and graceful fallback).

📦 Installation & Configuration

1. Install via npm / bun

npm install elizaos-plugin-security-gate
# or
bun add elizaos-plugin-security-gate

2. Add to Character JSON

{
  "name": "SecureAgent",
  "plugins": ["elizaos-plugin-security-gate"]
}

By default, the plugin runs in Local Deterministic Mode with no external network access.

2. (Optional) Configure Remote Micro-Oracle Verification

If you wish to route safety checks through an external micro-oracle:

{
  "name": "SecureAgent",
  "plugins": ["elizaos-plugin-security-gate"],
  "settings": {
    "secrets": {
      "SECURITY_GATE_URL": "https://your-security-gate-oracle.example.com",
      "SECURITY_GATE_API_KEY": "your-optional-api-key"
    }
  }
}

🧱 Components Included

  • securityGatePreHandler (ChatPreHandler): Fail-closed inbound guard that intercepts and analyzes inbound messages in sub-millisecond (<1ms) time before LLM inference or action dispatch, short-circuiting adversarial turns immediately.
  • SECURITY_GATE_EVALUATOR: Evaluates conversational turns for prompt injections, jailbreaks, or policy violations and logs audit records into agent memory via standard Evaluator processors.
  • INSPECT_SAFETY Action: Explicitly audits code snippets, transaction calldata, or dynamic instructions before critical tool execution (auto-detecting code snippets or accepting explicit isCode options). Delivers strictly typed Content and ContentValue callbacks.
  • securityStatusProvider: Injects active security gate defense status and threat telemetry into the agent's context memory.

💻 Action Callback Contract (ContentValue)

When calling INSPECT_SAFETY, the action callback emits structured telemetry adhering to ElizaOS core typing:

import { inspectSafetyAction } from "@elizaos/plugin-security-gate";

const result = await inspectSafetyAction.handler(
  runtime,
  message,
  state,
  {},
  async (callbackContent) => {
    // callbackContent conforms to Content
    console.log(callbackContent.text);
    // callbackContent.data conforms to Record<string, ContentValue>
    const { verdict, riskScore, threats, executionTimeMs, oracle, isCode } = callbackContent.data as {
      verdict: "ALLOW" | "WARN" | "BLOCK";
      riskScore: number;
      threats: string[];
      executionTimeMs: number;
      oracle?: boolean;
      isCode?: boolean;
    };
  }
);

🧪 Testing

bun test plugins/plugin-security-gate
# or
bunx vitest run

Comprehensive unit tests cover prompt injection blocking, zero-width character evasion normalization, dangerous command pattern detection, safe pass-through, and local fail-safe handling.


🌐 Multi-Chain Verified Smart Contracts

Security Gate x402 is live and verified across major EVM production networks. You can easily query verified contract addresses using the built-in helper:

import { getSecurityGateContracts } from "@elizaos/plugin-security-gate";

// Retrieve verified addresses for Arbitrum One (Chain ID 42161)
const arb = getSecurityGateContracts(42161);
console.log("Safe Guard:", arb.contracts.safeSecurityGateGuard);
console.log("Escrow:", arb.contracts.agentEscrow);
console.log("Native USDC:", arb.tokens.usdc);

Verified Mainnet Deployments

| Contract | Polygon Mainnet (137) | Base Mainnet (8453) | Arbitrum One (42161) | | :--- | :--- | :--- | :--- | | SafeSecurityGateGuard | 0x5cC5...f173 | 0x306e...F408 | 0x306e...F408 | | AgentCreditOracle | 0x6418...aB93 | 0x227e...be93 | 0x227e...be93 | | AgentComplianceRegistry | 0x2829...76DD | 0x821d...292D | 0x821d...292D | | AgentEscrow | 0x8ACa...389d | 0x99FE...d278 | 0x99FE...d278 | | AgentInsurancePool | 0xE67F...69C6 | 0x9030...3Ef2 | 0x9030...3Ef2 | | AgentLendingPool | 0xe43a...82cF | 0x5cC5...f173 | 0x5cC5...f173 | | AgentFactoringPool | 0xd0Aa...5BB0 | 0x6418...aB93 | 0x6418...aB93 | | AgentTreasuryVault | 0xfCf3...C638 | 0xF8e1...ae55 | 0xF8e1...ae55 | | SecurityGateConsumer | 0x9E3d...1DDA | 0xdC6C...aB35 | 0xdC6C...aB35 |


📚 Documentation & Specifications


📄 License

MIT