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

envtrap

v3.1.0

Published

Zero-Configuration Runtime Secret Leak Detector for Node.js 18+

Readme

envtrap

A zero-configuration runtime secret leak detector and egress firewall for Node.js.

envtrap wraps your Node.js application and intercepts every outbound channel in real time — before secrets, credentials, or sensitive environment variables can be exfiltrated by malicious code, compromised packages, or insider threats.

Unlike static analysis (SAST) tools that scan source code at build time, envtrap operates at execution time — inspecting actual traffic, subprocesses, DNS queries, and output streams as they happen.


Developer & Architecture Documentation

If you want to understand how the codebase works, how modules are intercepted, or how to contribute, refer to our modular developer guides:


Interception Channels

envtrap intercepts leaks across five distinct runtime vectors:

  • HTTPS/HTTP MITM Proxy (network channel): Routes outbound TCP connections through an ephemeral, in-memory loopback proxy. Intercepts request headers, URLs, and payloads, verifying them before forwarding. Ephemeral TLS certificates are generated on-the-fly and trusted by injecting a temporary Root CA into NODE_EXTRA_CA_CERTS.
  • Standard Output Scanning (stdout / stderr channels): Hooks standard output streams to search for registered credentials. Matches are redacted using a secure SHA-256 fingerprint placeholder.
  • Subprocess Environment Check (child_process channel): Hooks Node.js process creation modules (child_process.spawn, exec, fork, and their synchronous equivalents) at the binding layer to prevent sensitive credentials from being inherited by child processes.
  • DNS Resolution Auditing (dns channel): Hooks the core node:dns module to detect secrets encoded directly inside hostname resolution queries.
  • High-Entropy Label Detection: Uses Shannon entropy analysis on subdomain labels to automatically flag potential base64/hex DNS tunneling vectors.

Installation

# Global install
npm install -g envtrap

# Dev dependency
npm install --save-dev envtrap

# One-off, no install
npx envtrap run node app.js

Usage

Prefix your existing Node.js startup command with envtrap run:

envtrap run node app.js

# Express / Fastify
envtrap run node server.js

# NestJS
envtrap run node dist/main.js

# Next.js (server-side protection)
envtrap run npm run start

CLI Flags

# Custom .env file path
envtrap run --env-file .env.production node app.js

# Disable HTTPS MITM proxy (bypasses network interception)
envtrap run --no-mitm node app.js

# Verbose output (logs cert issuance and network handshake information)
envtrap run --verbose node app.js

# Quiet mode (suppress terminal alerts, prints exit summary only)
envtrap run --quiet node app.js

# Append JSONL events to a custom file
envtrap run --log-file logs/envtrap.jsonl node app.js

# Verify the syntax of envtrap.json
envtrap check

Configuration (envtrap.json)

You can customize rules by creating an envtrap.json file in your project root:

{
  "channels": {
    "stdout":        "warn",
    "stderr":        "warn",
    "network":       "block",
    "child_process": "warn",
    "dns":           "block"
  },
  "exclusions": {
    "domains": ["api.stripe.com", "api.openai.com"],
    "paths":   ["test/**", "**/__tests__/**"]
  },
  "entropy": {
    "threshold": 3.5,
    "minLength": 12
  },
  "quiet":   false,
  "logFile": null
}

Channel Modes

  • block: Halts execution, closes the network stream, or interrupts the system command immediately when a secret leak is detected.
  • warn: Emits a warning log detailing the leak event, redacts the matched content, and allows the operation to proceed.
  • off: Disables the corresponding interception channel entirely.

Exclusions & Subdomain Bypasses

  • domains: Bypasses network interception for specific target hosts. These domains are automatically appended to the environment's NO_PROXY parameters.
  • paths: Glob patterns targeting source files. Detections originating from source code inside these paths are ignored.