Zero-dependency outbound HTTP egress, User-Agent email leak, and context PII auditor for Claude Code, Codex CLI, and MCP configs.
In anthropics/claude-code#55743 and #107757, developers discovered that Claude Code reads oauthAccount.emailAddress from ~/.claude.json, injects it into every session's system prompt as a # userEmail block, and then autonomously copies that email into outbound User-Agent headers (curl -A, Python requests) or URL query strings when hitting third-party APIs like SEC EDGAR or Nominatim.
Even after # userEmail is patched upstream, coding agents still ingest personal emails, phone numbers, local OS usernames (/Users/<user>), and tokens from ~/.gitconfig, CLAUDE.md, AGENTS.md, and scraped browser/email outputs. Once those strings enter the context window, any Bash, WebFetch, WebSearch, or remote SSH MCP tool call can transmit them to external domains without a per-request identity check.
egressleak audits your local coding agent setup across two planes and can emit a deterministic PreToolUse guardrail hook that blocks outbound email or token leaks before execution.
npx egressleakGenerate a deterministic Claude Code PreToolUse guardrail hook and telemetry opt-out config:
npx egressleak --emit-hookFail CI or pre-commit checks if CRITICAL or HIGH leaks are detected:
npx egressleak --fail-on HIGHRunning npx egressleak across 153 local transcripts (126 Claude Code sessions in ~/.claude/projects/**/*.jsonl and 27 Codex CLI sessions in ~/.codex/sessions/**/*.jsonl, containing 1,928 deduplicated tool calls) surfaced two false-positive traps that naive regex scanners miss, plus real leaks:
- Synthetic AI trailer email inflation (
259synthetic vs77real PII hits): A raw email regex across the 153 transcripts matched336email occurrences. However,259of those (77.1%) were synthetic[email protected]andexample.comstrings injected by Claude Code's ownCo-Authored-Bycommit trailer instructions.egressleakseparates synthetic trailer emails (EGL006) from real personal/customer PII (EGL013), isolating the77genuine email occurrences across8real domains (gmail.com53,mcxindia.com11,prince.sh4,adelev8.com4,nvidia.com2,aqr.com1). - Loopback dev-server traffic vs external internet egress (
19loopback vs11external): Outbound URL extraction across1,928tool calls matched30HTTP requests.19of those (63.3%) targeted local dev servers (127.0.0.1/localhost).egressleakisolates loopback traffic (EGL014) from the11external internet requests (q.prince.sh9,gemini.google.com2). - Caught real leaks:
2outbound requests (EGL008) passed?authuser=<REDACTED_EMAIL>@gmail.comdirectly in URL query parameters.1outboundcurlPOST (EGL010) uploaded a local payload file (-d @$TMP_PAYLOAD) to an external endpoint.3MCP servers in~/.claude.json(EGL003) piped tool arguments over remotessh root@<REDACTED_IP>tunnels.userID,machineID,cachedStatsigGates, andcachedGrowthBookFeatures(EGL002) were active in~/.claude.jsonwithoutDISABLE_TELEMETRY=1orCLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1.
| Rule | Plane | Severity | What it detects |
|---|---|---|---|
EGL001 |
Identity | CRITICAL |
oauthAccount.emailAddress stored in ~/.claude.json and auto-injected into session context (#55743 / #107757) |
EGL002 |
Identity | HIGH |
Persistent tracking IDs (userID, machineID, cachedStatsigGates, cachedGrowthBookFeatures) active without telemetry opt-out |
EGL003 |
Identity | HIGH |
Remote SSH (ssh root@<IP>) or network-tunneled MCP servers configured in ~/.claude.json |
EGL004 |
Identity | MEDIUM |
Personal/work email hardcoded in ~/.gitconfig, ~/.claude/CLAUDE.md, or ~/.agents/AGENTS.md |
EGL005 |
Identity | MEDIUM |
Local OS username path (/Users/<USER>) injected across session transcripts |
EGL006 |
Identity | LOW |
Synthetic AI trailer emails ([email protected], example.com) filtered out of PII counts |
EGL007 |
Egress | CRITICAL |
Real email or operator identity sent in outbound User-Agent header (curl -A, -H "User-Agent: ...", #107757) |
EGL008 |
Egress | CRITICAL |
Email or personal identifier leaked in outbound URL query parameters (?authuser=, ?email=, ?contact=) |
EGL009 |
Egress | CRITICAL |
Bearer token, API key (sk-, ghp_, AIza), or query secret passed in outbound HTTP request |
EGL010 |
Egress | HIGH |
Local file (-d @file, --data-binary) or sensitive env var uploaded via outbound HTTP POST |
EGL011 |
Egress | HIGH |
External non-loopback domain contacted via Bash, WebFetch, or exec_command |
EGL012 |
Egress | MEDIUM |
Email address, local username path, or secret token leaked inside a WebSearch query |
EGL013 |
Egress | MEDIUM |
Real personal or customer email domains persisted in plaintext .jsonl transcripts |
EGL014 |
Egress | INFO |
Loopback HTTP requests (127.0.0.1, localhost) separated from external internet egress |
All terminal and JSON output automatically masks sensitive tokens before printing:
- Real emails:
<REDACTED_EMAIL>@gmail.com(domain preserved for attribution, local inbox masked) - Public IPv4 addresses:
<REDACTED_IP>(127.0.0.1preserved for loopback verification) - API keys & Bearer tokens:
<REDACTED_TOKEN> - OS home paths:
/Users/<USER>
- Static & transcript-level visibility only:
egressleakinspects.jsonlsession transcripts and agent config files on disk. If an agent executes a compiled binary or a Python script whose outbound URL is constructed dynamically at runtime without appearing in the tool call arguments, transcript replay cannot see the destination host unless a network-level proxy (such asmitmproxyor PacketFilter/Little Snitch) is used. PreToolUsehook scope: The generatedegress-guard-hook.mjsinspectsBash,WebFetch, andWebSearchtool inputs in Claude Code. It blocks literal email addresses,User-Agentcontact strings, and secret tokens in tool arguments, but does not inspect child processes spawned inside an already-approved script file.
MIT

