You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The hook system captures complete tool responses to History/raw-outputs/*.jsonl files. When MCP tools return sensitive data (OAuth credentials, API keys, PII, database passwords), these secrets:
Persist on disk in user-readable files
Are naturally read by Claude Code during debugging workflows
Get exposed to the AI provider when users ask Claude to analyze sessions
The primary risk is not git commits (GitHub scanning catches those) - it's that files containing secrets exist in a location where Claude Code's Read tool naturally accesses them during normal operation.
Attack Vector
Scenario:
User integrates MCP server (google-calendar, stripe, database, etc.)
MCP tool response contains credentials/secrets
Hook captures full response to raw-outputs/YYYY-MM-DD_all-events.jsonl
User encounters hook issue or wants to debug session
User asks: "Can you check my hook logs?"
Claude uses Read/Grep tools on raw-outputs directory
Secrets are transmitted to Anthropic servers
Now in AI provider's logs/training data
This is not hypothetical - it occurred in my own workflow today. (I ended up removing the MCP and writing a library based script, but that may not always be possible)
Severity: Medium-High (secrets exposed to AI provider during normal operation)
Exposure paths:
User asks Claude to debug hooks → Claude reads raw-outputs
User asks Claude to analyze session → Claude reads raw-outputs
User shares session ID for help → Helper reads raw-outputs
Automated analysis tools → Read raw-outputs
Persistence: Until user manually deletes files (most won't know to)
Questions for Discussion
Is complete tool response capture essential for hooks? Could hooks receive sanitized/summarized data instead?
Should Claude Code warn before reading raw-outputs? Similar to how it confirms before running dangerous commands?
Should raw-outputs be ephemeral by default? Auto-delete after session ends or after summary generation?
Should there be automatic redaction? Pattern-match and redact known sensitive fields before writing?
Is this a documentation gap or design issue? Should the hook system explicitly handle sensitive data differently?
Potential Solutions (Discussion Starters)
A. Sanitize at capture time
// In capture-all-events.tsfunctionsanitizeToolResponse(response: any): any{constSENSITIVE_PATTERNS=['client_secret','client_id','access_token','refresh_token','api_key','password','connection_string','private_key'];// Recursively redact matching keys}B.Ephemeralbydefault// Auto-delete in capture-session-summary.ts after summary generation// Raw outputs serve only for real-time observability, not historical analysisC.Readtoolprotection// Warn when Read/Grep targets raw-outputsif(filePath.includes('raw-outputs')){console.warn('⚠️ Warning: This file may contain sensitive data from tool responses');}D.Separatesensitivefromnon-sensitive// Two output streams:// - raw-outputs-safe/ (tool names, timing, basic metadata)// - raw-outputs-sensitive/ (full responses, auto-deleted)CurrentWorkaround
# Immediatemitigationecho"History/Raw-Outputs/">>.gitignorerm-rf.claude/History/Raw-Outputs/
# Long-term: Don't ask Claude to read these files
# ButthislimitsdebuggingcapabilityImpactonExistingUsers-UserswithMCPintegrationslikelyhavecredentialsinraw-outputsnow-Theymaynotrealizethesefilesexistorcontainsecrets-Standard"help me debug"requestscouldexposecredentials-Sessionsummariesactivelypointuserstoraw-outputsdirectoryRequestLookingforguidance on:
1.Whetherthisisconsideredexpectedbehaviororneedsaddressing2.Whatlevelofsanitizationisacceptablewithoutbreakingdebuggingworkflows3.Whetherthere's consensus on making raw-outputs ephemeral by default
4.IfthiswarrantsasecurityadvisorytoexistingusersNotrushingtoPR-wanttounderstandtheappropriatedesignfirst.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Summary
The hook system captures complete tool responses to
History/raw-outputs/*.jsonlfiles. When MCP tools return sensitive data (OAuth credentials, API keys, PII, database passwords), these secrets:The primary risk is not git commits (GitHub scanning catches those) - it's that files containing secrets exist in a location where Claude Code's Read tool naturally accesses them during normal operation.
Attack Vector
Scenario:
This is not hypothetical - it occurred in my own workflow today. (I ended up removing the MCP and writing a library based script, but that may not always be possible)
Affected MCP Integrations
Any MCP tool returning sensitive data:
Current "Protections" (Insufficient)
What works:
What doesn't protect:
Impact Analysis
Severity: Medium-High (secrets exposed to AI provider during normal operation)
Exposure paths:
Persistence: Until user manually deletes files (most won't know to)
Questions for Discussion
Is complete tool response capture essential for hooks? Could hooks receive sanitized/summarized data instead?
Should Claude Code warn before reading raw-outputs? Similar to how it confirms before running dangerous commands?
Should raw-outputs be ephemeral by default? Auto-delete after session ends or after summary generation?
Should there be automatic redaction? Pattern-match and redact known sensitive fields before writing?
Is this a documentation gap or design issue? Should the hook system explicitly handle sensitive data differently?
Potential Solutions (Discussion Starters)
A. Sanitize at capture time
All reactions