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

agent-security-context-pack

v0.1.0-alpha

Published

Runtime security scaffolding for local AI assistants - capability-based access control, tool-call firewall, and tamper-evident audit logging

Readme

Agent Security Context Pack

Runtime security scaffolding for local AI assistants. Provides capability-based access control, a tool-call firewall, and tamper-evident audit logging.

Why This Exists

AI assistants running locally can read files, browse the web, execute tools, and interact with external services. Without proper guardrails, they're vulnerable to:

  • Prompt injection from malicious web content or emails
  • Data exfiltration to attacker-controlled endpoints
  • Credential theft through path traversal or forbidden file access
  • Supply chain attacks via compromised tools/skills

This package provides defense-in-depth security that works at runtime, not through prompts.

Features

  • Capability Tiers (T0-T3): Progressive permission levels from read-only to shell execution
  • Tool-Call Firewall: 7-stage validation pipeline for every operation
  • Taint Tracking: Labels untrusted data and blocks it from dangerous contexts
  • Path Validation: Blocks traversal attacks and forbidden paths (.ssh, .env, etc.)
  • Domain Validation: Allowlists, blocklists, and SSRF protection
  • Shell Validation: Blocks dangerous command patterns
  • Rate Limiting: Token-bucket algorithm prevents abuse
  • Approval Queue: Step-up authentication for sensitive operations
  • Hash-Chained Audit Logs: Tamper-evident logging with Merkle proofs
  • Tool Registry: Hash-pinned tool verification

Installation

npm install agent-security-context-pack

Quick Start

import {
  createSecurityContext,
  PolicyEngine,
  TrustLevel,
} from 'agent-security-context-pack';

// Load policy from YAML
const policy = await PolicyEngine.fromFiles(['./policy.yaml']);

// Create security context
const { firewall, taintTracker, auditLogger } = createSecurityContext({
  policy,
  auditPath: './audit.ndjson',
});

// Wrap your tool executor
const secureExecutor = firewall.wrap(async (tool, args) => {
  // Your tool execution logic
  return await executeTool(tool, args);
});

// Mark external data as untrusted
const webContent = await fetch('https://example.com');
taintTracker.taint(webContent, TrustLevel.UNTRUSTED, {
  id: 'web:example.com',
  type: 'web_fetch',
});

// Execute tool calls through the firewall
try {
  const result = await secureExecutor({
    id: 'call-123',
    tool: 'file:read',
    arguments: { path: '/path/to/file' },
    sourceTrust: TrustLevel.TRUSTED,
    context: { sessionId: 'session-1', agentId: 'agent-1' },
  });
} catch (error) {
  if (error instanceof ApprovalRequiredError) {
    // Handle approval flow
  }
}

Security Guarantees

| Threat | Protection | How | |--------|------------|-----| | Prompt injection | High | Taint tracking blocks untrusted data in shell/file/email contexts | | Data exfiltration | High | Domain allowlists + approval for external sends | | Credential theft | High | Forbidden paths block .ssh, .env, *.pem, etc. | | Path traversal | High | Normalized paths, blocked .. sequences | | Shell injection | High | T3 disabled by default, dangerous patterns blocked | | Supply chain attacks | Medium | Hash-pinned tools, signature verification | | Audit tampering | High | Hash-chained logs with Merkle proofs |

See THREAT_MODEL.md for detailed analysis.

Documentation

Examples

Architecture

┌─────────────────────────────────────────────────────────────┐
│                     Tool Call Request                        │
└─────────────────────────────────────────────────────────────┘
                              │
                              ▼
┌─────────────────────────────────────────────────────────────┐
│                    FIREWALL (7 Stages)                       │
│  ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐           │
│  │ Schema  │→│  Tier   │→│Validator│→│  Trust  │→ ...      │
│  │  Check  │ │  Check  │ │  Check  │ │  Check  │           │
│  └─────────┘ └─────────┘ └─────────┘ └─────────┘           │
└─────────────────────────────────────────────────────────────┘
                              │
              ┌───────────────┼───────────────┐
              ▼               ▼               ▼
         ┌─────────┐    ┌─────────┐    ┌─────────┐
         │ ALLOWED │    │ DENIED  │    │APPROVAL │
         └─────────┘    └─────────┘    │REQUIRED │
                                       └─────────┘

Policy Configuration

Policies are defined in YAML:

tiers:
  T0_READ_ONLY:
    enabled: true
    requires_approval: never
    operations:
      - "file:read"
      - "web:fetch"

  T2_WRITE_SEND:
    enabled: false  # Disabled by default
    requires_approval: always
    operations:
      - "file:write"
      - "email:send"

resources:
  filesystem:
    forbidden_paths:
      - "${HOME}/.ssh"
      - "**/.env"

See POLICY/capabilities.yaml for full reference.

Known Limitations (v0.1.0-alpha)

This is an alpha release. The core security primitives work and are tested, but some features are stubbed:

| Feature | Status | Notes | |---------|--------|-------| | Firewall | Working | 7-stage validation, all validators functional | | Taint Tracking | Working | Trust levels, propagation, hard blocks | | Path Validation | Working | Traversal detection, forbidden paths | | Domain Validation | Working | Allowlists, SSRF protection | | Shell Validation | Working | Dangerous pattern detection | | Rate Limiting | Working | Token bucket, in-memory only | | Hash Verification | Stub | HashVerifier.verify() always returns true | | Signature Verification | Stub | No real Ed25519 - placeholder only | | Audit Persistence | Stub | Logs to memory, not disk | | Lock File I/O | Stub | In-memory only | | CLI (ascp) | Not Implemented | Planned for v0.2.0 | | YAML Parsing | Partial | codeExecution/skillInstall use hardcoded defaults |

What works today: Firewall, taint tracking, all validators, approval queue, hash-chained audit logs (in memory).

What's coming: Persistent storage, real cryptography, CLI tools. See the roadmap below.

Roadmap

| Version | Focus | Key Features | |---------|-------|--------------| | v0.2.0 | Persistence & CLI | Audit log persistence, lock file I/O, basic CLI | | v0.3.0 | Real Cryptography | Ed25519 signatures, actual hash verification | | v0.4.0 | Production | Policy hot-reload, MCP server wrapper | | v1.0.0 | Stable | Security audit, full feature parity |

Requirements

  • Node.js >= 18.0.0
  • TypeScript >= 5.0 (for development)

License

MIT - See LICENSE

Contributing

Contributions welcome. Please read the threat model first to understand security requirements.

Security

If you discover a security vulnerability, please report it privately rather than opening a public issue.