New:Microsoft Teams Notifications Are Now Available in Socket.Learn more
Get Started

phantom-secrets

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

phantom-secrets

Prevent AI coding agents from leaking your API keys. Replaces real secrets with phantom tokens; a local proxy swaps them back at the network layer.

latest
Source
npmnpm
Version
0.6.0
Version published
Weekly downloads
23
15%
Maintainers
2
Weekly downloads
 
Created
Source

Phantom Secrets

AI uses your keys. Safely.

npm GitHub stars License: MIT

AI coding agents read your .env files, putting API keys into LLM context windows where they can leak via prompt injection, session logs, malicious MCP servers, or training data.

Phantom replaces real secrets with inert phm_ tokens. A local reverse proxy swaps them back at the network layer. The AI never sees a real key.

Install

npm install -g phantom-secrets

Or run directly:

npx phantom-secrets init

Quick Start

# Protect your secrets
$ npx phantom-secrets init
# Detects .env files, stores real secrets in OS keychain,
# rewrites .env with phantom tokens

# Run your AI tool through the proxy
$ phantom exec -- claude
# Proxy on 127.0.0.1 swaps phm_ tokens with real keys at the network layer

How It Works

  • phantom init reads .env, stores real secrets in the OS keychain, rewrites values with phm_ tokens
  • phantom exec -- claude starts a local reverse proxy that sets OPENAI_BASE_URL=http://127.0.0.1:PORT/openai (and equivalents)
  • API calls hit the proxy, which replaces phantom tokens with real secrets and forwards over TLS
  • When the session ends, the proxy shuts down. Phantom tokens are worthless outside the proxy.

27 Commands

CommandDescription
phantom initImport .env secrets into vault, rewrite with phantom tokens
phantom exec -- <cmd>Start proxy and run a command with secret injection
phantom start / stopManage proxy lifecycle (standalone/daemon mode)
phantom listShow secret names stored in vault (never values)
phantom add <KEY> <VAL>Add a secret to the vault
phantom remove <KEY>Remove a secret from the vault
phantom reveal <KEY>Print a secret value (or --clipboard to copy)
phantom statusShow proxy state, vault info, and mapped services
phantom rotateRegenerate all phantom tokens (old ones become invalid)
phantom doctorCheck configuration and vault health (--fix to auto-repair)
phantom checkScan for unprotected secrets (pre-commit hook, --staged, --runtime)
phantom wrapWrap package.json scripts with phantom exec automatically
phantom unwrapRestore original package.json scripts
phantom watchWatch .env files and auto-detect new unprotected secrets
phantom why <KEY>Explain why a key is or is not protected
phantom copy <KEY> --to <dir>Copy a secret to another project's vault
phantom syncPush secrets to Vercel / Railway
phantom pullPull secrets from Vercel / Railway into vault
phantom setupConfigure Claude Code MCP server + hooks
phantom envGenerate .env.example for team onboarding
phantom exportExport vault to encrypted backup file
phantom importImport vault from encrypted backup
phantom login / logoutAuthenticate with Phantom Cloud via GitHub OAuth
phantom cloud pushPush encrypted vault to Phantom Cloud
phantom cloud pullPull and decrypt vault from Phantom Cloud
phantom team list/create/members/inviteTeam vault management

MCP Server

Phantom ships a companion MCP server package so AI coding tools can manage secrets directly -- without ever seeing real values. 24 tools available.

# Claude Code
claude mcp add phantom-secrets-mcp -- npx phantom-secrets-mcp

# Cursor / Windsurf / Codex
# Add to your MCP config:
{"phantom": {"command": "npx", "args": ["phantom-secrets-mcp"]}}

See phantom-secrets-mcp on npm.

Key Features

  • OS keychain storage -- macOS Keychain / Secure Enclave, Linux Secret Service, encrypted file fallback for CI
  • 256-bit CSPRNG tokens -- phm_ prefix, rotatable on demand
  • Streaming proxy -- Full SSE/streaming support for OpenAI, Anthropic, and other APIs
  • Response scrubbing -- Prevents secrets from leaking in API responses back to the AI
  • Smart detection -- Heuristic engine distinguishes secrets from config values
  • Platform sync -- Push/pull secrets to Vercel and Railway
  • Cloud sync -- E2E encrypted zero-knowledge vault sync across machines (ChaCha20-Poly1305 + Argon2id)
  • Team vaults -- Shared vaults with role-based access control
  • Pre-commit hook -- Blocks commits containing unprotected secrets
  • Script wrapping -- phantom wrap patches package.json so every npm script runs through the proxy
  • Watch mode -- phantom watch monitors .env files for new unprotected secrets
  • Export/import -- Encrypted backup and restore with passphrase protection

Platform Support

PlatformArchitectureStatus
macOSApple Silicon (arm64)Supported
macOSIntel (x64)Supported
Linuxx64Supported
Linuxarm64Supported

Security

  • Secrets never on disk in your project directory
  • Proxy binds to 127.0.0.1 only -- never exposed to the network
  • Secrets zeroized from memory after injection
  • Zero-knowledge cloud -- server stores only ciphertext

See SECURITY.md for the full threat model.

License

MIT

Keywords

secrets

FAQs

Package last updated on 04 May 2026

Related posts