> ## Documentation Index
> Fetch the complete documentation index at: https://envtrap.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction

> envtrap v2.1 — Runtime security for Node.js. Block secret exfiltration before it leaves your process.

<img className="block" src="https://mintcdn.com/envtrap/1TCiZlEPtUuh3CEz/logo.png?fit=max&auto=format&n=1TCiZlEPtUuh3CEz&q=85&s=27d942832a7ef72dcd182fe91413ca3c" alt="envtrap logo" style={{ width: "140px", marginBottom: "2rem" }} width="272" height="270" data-path="logo.png" />

# What is envtrap?

**envtrap** is an open-source runtime security tool for **Node.js** applications. It wraps your process 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 tools (SAST) that scan source code at build time, envtrap operates **at execution time** inside the Node.js runtime — inspecting actual traffic, child processes, DNS queries, and stdout/stderr output as they happen.

## The Problem

Modern Node.js applications are rich with sensitive data:

* `STRIPE_SECRET_KEY`, `DATABASE_URL`, `OPENAI_API_KEY` …
* Thousands of transitive npm dependencies with supply-chain risk
* No runtime visibility into *what* leaves your process

A single compromised package — even a deep transitive dependency — can silently exfiltrate your secrets. Traditional security tools won't catch this because:

| Tool             | What it does                   | What it misses                    |
| ---------------- | ------------------------------ | --------------------------------- |
| SAST / linting   | Scans source code for patterns | Runtime behavior, dynamic secrets |
| Secrets scanners | Finds secrets committed to git | Secrets only present at runtime   |
| WAFs / Firewalls | Filters inbound traffic        | Outbound, process-level egress    |
| EDR / AV         | Detects known malware          | Legitimate runtime exfiltration   |

## The Solution

envtrap solves this by wrapping your Node.js process with a **zero-instrumentation runtime guard** that:

* 🔒 Intercepts HTTPS / HTTP outbound requests via an in-memory MITM proxy
* 🔒 Monitors stdout / stderr for secret patterns and redacts them
* 🔒 Blocks unauthorized child processes and `execSync` calls
* 🔒 Detects DNS tunneling exfiltration attempts
* 🔒 Synchronizes dynamically-rotated runtime secrets in real time
* 🔒 Automatically bypasses local loopback traffic from the proxy

```bash theme={null}
# Before: vulnerable
node app.js

# After: protected
envtrap run node app.js
```

That's it. No code changes. No SDK to install. No agent to manage.

## Key Features

<CardGroup cols={2}>
  <Card title="Zero Instrumentation" icon="bolt">
    Drop envtrap in front of any `node` command. Works with Express, NestJS, Next.js, Fastify, and bare scripts.
  </Card>

  <Card title="HTTPS Interception" icon="shield">
    Native OpenSSL RSA — certificates generated in \~5ms. Loopback traffic bypassed automatically via `NO_PROXY`.
  </Card>

  <Card title="Entropy Detection" icon="chart-bar">
    Shannon entropy analysis catches high-entropy credential strings including dynamically-rotated secrets.
  </Card>

  <Card title="DNS Tunneling Guard" icon="network-wired">
    Detect and block DNS-based exfiltration via encoded subdomains, covering both callback and promise APIs.
  </Card>

  <Card title="Real-Time Sync" icon="arrows-rotate">
    `process.env` Proxy + `MessageChannel` broadcasts secret rotations to the ESM loader thread instantly.
  </Card>

  <Card title="Configurable Policy" icon="sliders">
    Fine-tune `block` vs `warn` per channel via `envtrap.json`. Path exclusions and domain allowlists supported.
  </Card>
</CardGroup>

## What's New in v2.1.0

<CardGroup cols={2}>
  <Card title="Native RSA Key Generation" icon="key">
    TLS certificate synthesis reduced from \~200ms to \~5ms using Node's `crypto.generateKeyPairSync` (C++ OpenSSL).
  </Card>

  <Card title="O(n) Chunk Scanner" icon="gauge">
    Eliminated O(n²) `Buffer.concat` in the MITM proxy — now uses a sliding-window overlap scanner.
  </Card>

  <Card title="Shell Injection Prevention" icon="terminal">
    All system CA tooling migrated from `execSync` template strings to safe `execFileSync` argument arrays.
  </Card>

  <Card title="RFC 5280 Cert Serials" icon="certificate">
    Certificate serial numbers now use `crypto.randomBytes(20)` — no more `Date.now()` collision risk.
  </Card>

  <Card title="Live Secrets Sync" icon="satellite-dish">
    Runtime `process.env` mutations are broadcast to the ESM loader thread via `MessageChannel` immediately.
  </Card>

  <Card title="Automatic NO_PROXY" icon="circle-xmark">
    Loopback addresses and `exclusions.domains` are automatically added to `NO_PROXY`/`no_proxy`.
  </Card>
</CardGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Quickstart" icon="rocket" href="/quickstart">
    Get envtrap running in under 60 seconds.
  </Card>

  <Card title="How It Works" icon="book-open" href="/how-it-works/runtime-interception">
    Deep dive into the runtime interception architecture.
  </Card>

  <Card title="Configuration" icon="gear" href="/configuration/envtrap-json">
    Customize channels, exclusions, and policies.
  </Card>

  <Card title="CLI Reference" icon="code" href="/api-reference/endpoint">
    Full reference for the `envtrap` CLI.
  </Card>
</CardGroup>
