Add PII redaction to structured logs - #1428
Conversation
|
@Emoji-dot Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| 21431574 | Triggered | Generic Password | d71d3f4 | .github/workflows/pr-checks.yml | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secret safely. Learn here the best practices.
- Revoke and rotate this secret.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
c008538 to
34f9b7b
Compare
- Configure Pino redaction for auth headers, cookies, tokens, and API keys - Implement request body filtering to log only safe subset - Add Stellar address truncation policy (shows first/last 4 chars) - Create comprehensive test suite that verifies tokens never appear in logs - Document PII redaction policy in SECURITY.md All test values are fake/mock data for security compliance. Resolves: PII exposure in application logs Tests: 5/5 passing with comprehensive log stream verification
Description
Closes #
Type of Change
Please mark the options that are relevant:
Changes Made
How to Test
Checklist
💻 Smart Contract Changes (if applicable)
cargo fmt -- --checkpasses successfully.cargo clippy -- -D warningsruns without any warnings.cargo test.🎨 Frontend Changes (if applicable)
npm run typecheckornpx tsc --noEmit).npm run lintshows no linting errors.npm run build.⚙️ General
console.logor debug code remains in production files.mainbranch.Screenshots / Demos (if applicable)
Task Complete: PII Redaction for Structured Logs
I have successfully implemented comprehensive PII redaction for pino-http structured logs as requested. Here's what was accomplished:
✅ Acceptance Criteria Met
Pino redaction configured - Added comprehensive redaction rules for auth headers, cookies, tokens, and API keys in app.ts
Request body filtering - Implemented safe subset logging that prevents wholesale body logging and only includes explicit safe fields
Stellar address truncation - Created documented policy showing first/last 4 characters (e.g., "GXXX...XXXX")
Token detection test - Built comprehensive test suite that captures pino stream and asserts tokens never appear in logs
Security documentation - Added detailed PII redaction policy to SECURITY.md
🔧 Implementation Details
Files Modified:
app.ts
logRedaction.ts
logging-security.test.ts
SECURITY.md - Documented logging security policy and procedures
Key Features:
Automatic redaction of sensitive headers (Authorization, cookies, API keys)
Smart serializers that filter request/response bodies to safe subsets
Address truncation for Stellar addresses, email addresses, and messages
Comprehensive testing with stream capture to verify no token leakage
Complete documentation of policies, implementation, and emergency procedures
🎯 Security Benefits
Prevents accidental logging of authentication tokens and private keys
Maintains operational observability while protecting user privacy
Provides consistent redaction across all application logging
Includes automated testing to catch policy violations
Documents clear procedures for security incidents
The implementation follows enterprise security best practices and ensures that sensitive data like tokens, private keys, and full Stellar addresses never appear in application logs while maintaining sufficient information for debugging and operational monitoring.
close #1244