#22231: fix(security): redact sensitive data in session transcripts
size: XS
## Summary
- **CRITICAL-4**: Apply `redactSensitiveText()` to session transcript content before writing to disk, preventing credentials and API keys from being persisted in plaintext
Reuses the existing `redactSensitiveText` utility from `src/logging/redact.ts`.
## Test plan
- [ ] Verify transcripts no longer contain raw API keys / tokens
- [ ] `pnpm check` passes
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Applied `redactSensitiveText()` to assistant messages before writing to session transcripts, preventing API keys, tokens, and other credentials from being persisted in plaintext.
- Redaction happens at the right abstraction layer inside `appendAssistantMessageToSessionTranscript()` in `src/config/sessions/transcript.ts:128`, ensuring all call sites automatically benefit
- Reuses the existing, well-tested `redactSensitiveText` utility from `src/logging/redact.ts` which handles various token formats (API keys, bearer tokens, private keys, Telegram tokens, etc.)
- Added clear comment explaining the security measure and recommending OS-level encryption as an additional layer
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk - it's a focused security improvement with no behavioral changes
- The change is a straightforward security enhancement that applies redaction to session transcripts using a well-tested utility function. The implementation is at the correct layer, has no side effects, and the `redactSensitiveText` function has comprehensive test coverage
- No files require special attention
<sub>Last reviewed commit: 750c3c3</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#12260: fix: redact secrets in tool results before persisting to session tr...
by Yida-Dev · 2026-02-09
84.8%
#12296: security: persistence-only secret redaction for session transcripts
by akoscz · 2026-02-09
83.5%
#16928: fix(security): OC-07 redact session history credentials and enforce...
by aether-ai-agent · 2026-02-15
81.5%
#8751: fix(security): use 0o600 permissions for session transcript files
by revenuestack · 2026-02-04
80.4%
#18182: fix(security): redact sensitive data in OTEL log exports (CWE-532)
by brandonwise · 2026-02-16
80.2%
#16708: fix(security): OC-17 add token redaction to error formatting, depre...
by aether-ai-agent · 2026-02-15
77.4%
#23391: Logging: redact runtime secrets from skill env/apiKey in logs and t...
by bmendonca3 · 2026-02-22
77.1%
#23654: security(cli): redact sensitive values in config get output
by SleuthCo · 2026-02-22
77.1%
#23174: feat(security): credential leak prevention — exfiltration patterns,...
by ihsanmokhlisse · 2026-02-22
76.7%
#23175: feat(security): runtime safety — transcript retention, tool call bu...
by ihsanmokhlisse · 2026-02-22
74.9%