Claude Code & MCP Secret Leaks: 5 Security Blind Spots in AI Coding Tools & Zero-Trust Hardening
This article dissects five critical security blind spots in AI coding assistants like Claude Code and MCP — including local approval persistence, .mcp.json supply-chain poisoning, gateway token cache flaws, indirect prompt injection, and static credential leakage — and provides a four-layer zero-trust hardening architecture with immediate audit commands.
Reading font

How a Single "Don't Ask Again" Dissolves the Secret Boundary
When an AI assistant proposes a command containing credentials, the confirmation dialog offers Yes or Yes, and don't ask again. Choosing the latter writes the entire approved command string — including embedded passwords or Bearer tokens — into .claude/settings.local.json. The tool adds this file to the user's global Git ignore (e.g., ~/.config/git/ignore) but does not add it to the project's .gitignore. On a new machine, in a container build ( COPY . .), or when a teammate without the same global rule commits, the file — and its clear-text secrets — lands in the repository. Traditional regex scanners often miss secrets hidden inside custom command-line arguments.
Five High-Frequency Blind Spots
Blind Spot 1: .claude/settings.local.json Stores Raw Credential-Bearing Commands
Claude Code records the exact approved command string in the project's .claude/settings.local.json. Example: PGPASSWORD=my_secret_pwd psql ... or a curl with an inline Bearer token. The global-ignore vs. project-ignore mismatch means the file can leak via git commit, docker build, or directory sync. Standard secret scanners rarely detect passwords embedded in arbitrary CLI arguments.
Blind Spot 2: .mcp.json as a Supply-Chain Poisoning Vector
Projects often commit .mcp.json to share MCP server declarations. Its stdio field is essentially a local process launch command list . If a malicious PR modifies .mcp.json and the reviewer only checks .py / .go diffs, loading that configuration executes attacker-controlled commands with the developer's full privileges — reading .env, ~/.ssh/, or .claude/settings.local.json and exfiltrating data.
Blind Spot 3: MCP Gateway Token Cache Mismatch & Auth Header Overwrite (CVE-2026-110195 / CVE-2026-110279)
CVE-2026-110195 (CVSS 5.4, versions 1.0.0–1.0.11, fixed in 1.1.0): IBM ContextForge MCP Gateway cached upstream access tokens using a key of gateway + user account + target audience without binding to the inbound JWT. A low-privilege API token could hit and reuse a high-privilege session's cached upstream Bearer token.
CVE-2026-110279 (CVSS 8.1, versions 1.0.0–1.1.0, fixed in 1.1.1): The gateway unconditionally rewrote the client-supplied X-Upstream-Authorization header to Authorization when forwarding to the upstream MCP service, allowing an authenticated caller to overwrite the gateway-managed upstream credentials and bypass per-user access control and audit attribution.
Blind Spot 4: Indirect Prompt Injection via Docs & Issues
Coding agents automatically ingest READMEs, GitHub Issues, dependency source code, and external pages. All external text entering the context becomes a potential control plane. An attacker hides a directive in a third-party library comment or Issue template that tricks the agent into reading local secrets ( .env, ~/.ssh/, .claude/settings.local.json) and exfiltrating them via an authorized HTTP tool, comment tool, or external MCP channel. The data-exfiltration loop closes when the agent simultaneously holds "read sensitive files" and "make outbound requests" capabilities.
Blind Spot 5: Long-Lived Static Keys in env & Full Host Environment Inheritance
Tutorials often place GITHUB_TOKEN, DATABASE_URL, AWS_SECRET_ACCESS_KEY directly in the MCP env field or rely on wholesale shell environment pass-through to MCP child processes. A lightweight MCP server that only needs to format code or query docs gains access to production DB passwords and cloud keys. If that third-party MCP package is compromised or has an over-read vulnerability, every static long-lived credential on the host is exposed at once .
30-Second Audit: Immediate Read-Only Checks
# 1. Check if repo tracks local approval files or has historical settings.local.json
git ls-files | grep -E '\.claude/settings\.local\.json|\.mcp\.json'
git log --all --full-history -- "**/.claude/settings.local.json"
# 2. Scan all local settings.local.json for sensitive keywords
grep -rnE --include="settings.local.json" \
"(PASSWORD|SECRET|TOKEN|Bearer|Authorization|AKIA|sk-[A-Za-z0-9]" \
~/src ~/.claude .claude 2>/dev/null
# 3. List long-lived cloud credential vars exposed to child processes (names only)
env | grep -E "^(AWS_|AZURE_|GOOGLE_|GITHUB_TOKEN|NPM_TOKEN|PGPASSWORD)" | cut -d= -f1Also review recent merged PRs for unexpected changes to .mcp.json, .cursor/mcp.json, or CI workflows. If using a centralized MCP gateway (e.g., ContextForge), verify version is 1.1.1 or newer.
Four-Layer Zero-Trust Hardening Blueprint
Layer 1 (Credential Layer): Eliminate Clear-Text, Inject via Keychain or Short-Lived Tokens
Keep only env-var references in scripts and rules: Write curl -H "Authorization: Bearer API_TOKEN" ... so the approval JSON stores only the variable name API_TOKEN; inject the actual value at subprocess launch, never persist in ~/.zshrc.
macOS: use Keychain or 1Password CLI: security CLI or op run inject secrets into memory at subprocess start; config files hold only placeholder references.
Prefer short-lived cloud credentials: Replace static AK/SK with AWS STS, GCP Workload Identity Federation, or OIDC tokens to shrink the exposure window to minutes.
Layer 2 (Repository Layer): Enforce Project .gitignore + Pre-Commit Blocking
Remove reliance on per-machine global ignores. Add to project .gitignore:
# AI Coding Agent local approvals & transient state (enforced at project level)
.claude/settings.local.json
.claude/*.local.md
.cursor/mcp.json.localFor container builds, add .claude/ to .dockerignore to prevent COPY . . from baking approval files into image layers. Enforce pre-commit + gitleaks with custom rules that block staging of .claude/settings.local.json or patterns like PGPASSWORD=, Authorization: Bearer.
Layer 3 (Gateway & MCP Layer): Minimal Env Whitelist + Treat Config as Code
Forbid full host env inheritance: Explicitly declare the one or two read-only variables each MCP server needs; drop the rest.
Gate .mcp.json via CODEOWNERS : Any PR adding or modifying .mcp.json requires explicit approval from security or core ops; no auto-merge.
Central gateway with strong identity binding & destructive-op confirmation: Ensure token-exchange cache keys bind the original inbound JWT; strip inbound X-Upstream-Authorization (and similar) headers at the edge proxy/gateway; require interactive confirmation for high-risk MCP tools (DB writes, messaging, repo permission changes).
Layer 4 (Sandbox Layer): Untrusted Repos & High-Risk Tasks Run in Containers
When analyzing an unfamiliar open-source project or running autonomous test-fix loops, use a DevContainer or lightweight VM . Mount only the project directory; do not mount ~/.ssh, ~/.aws, ~/.kube, or other credential directories. Restrict egress to model APIs and package mirrors. Even if a malicious document injects a prompt that compromises the model, the blast radius is a disposable, isolated workspace.
Two Pragmatic Boundaries
Don't ban AI coding tools outright for "absolute security." In controlled, first-party repos, moving local secrets to Keychain, adding project-level .gitignore, and enabling commit-time scanning stops the vast majority of accidental leaks without burdening every local read-only analysis with heavyweight approval gates.
Don't rely solely on regex scanners. Scanners are a last-resort safety net. As long as approval rules allow clear-text passwords into command history and JSON files, scanners will miss some. Source prevention — no clear-text persistence, runtime least privilege — is the fundamental fix.
About this article
For attribution, corrections or content rights, contact