Skip to content

Add PII redaction to structured logs - #1428

Open
Emoji-dot wants to merge 3 commits into
Akanimoh12:test-implement-dripsfrom
Emoji-dot:STELLAR-TIPZ
Open

Add PII redaction to structured logs#1428
Emoji-dot wants to merge 3 commits into
Akanimoh12:test-implement-dripsfrom
Emoji-dot:STELLAR-TIPZ

Conversation

@Emoji-dot

Copy link
Copy Markdown

Description

Closes #

Type of Change

Please mark the options that are relevant:

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 🧪 Tests (adding new tests or updating existing tests)
  • 📝 Documentation (changes to documentation/configs only)
  • 🚀 DevOps & CI/CD (changes to workflows, scripts, or templates)

Changes Made

How to Test

Checklist

💻 Smart Contract Changes (if applicable)

  • Running cargo fmt -- --check passes successfully.
  • Running cargo clippy -- -D warnings runs without any warnings.
  • All tests pass successfully using cargo test.
  • New unit or integration tests have been written to cover the changes.
  • No hardcoded values are present (e.g. addresses, fees) that should be configurable.

🎨 Frontend Changes (if applicable)

  • TypeScript compiles cleanly with no errors (npm run typecheck or npx tsc --noEmit).
  • Running npm run lint shows no linting errors.
  • The production build compiles successfully via npm run build.
  • Changes verified on local browser environment with Freighter/xBull/Albedo wallet.
  • Responsive design verified (tested on mobile, tablet, and desktop viewport sizes).
  • Keyboard navigation and accessibility (a11y) considerations are addressed.

⚙️ General

  • Code follows the project's coding standards and structure guidelines.
  • Self-reviewed the changes to ensure clean code with no commented-out code blocks.
  • No console.log or debug code remains in production files.
  • The branch is up-to-date with the main branch.

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

  • Enhanced pino-http configuration with redaction rules and custom serializers

logRedaction.ts

  • Utility functions for consistent PII handling

logging-security.test.ts

  • Comprehensive test suite for log security
    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

@drips-wave

drips-wave Bot commented Aug 26, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@gitguardian

gitguardian Bot commented Aug 26, 2026

Copy link
Copy Markdown

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

Since your pull request originates from a forked repository, GitGuardian is not able to associate the secrets uncovered with secret incidents on your GitGuardian dashboard.
Skipping this check run and merging your pull request will create secret incidents on your GitGuardian dashboard.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
21431574 Triggered Generic Password d71d3f4 .github/workflows/pr-checks.yml View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. 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


🦉 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.

Emoji-dot and others added 3 commits August 26, 2026 10:22
- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add PII redaction to structured logs

1 participant