Bahul and I gave a talk about a PII logging library solution in the Bay Area Scala meetup.
The Problem
Writing sensitive data in logs - PII, PHI etc.
Logging is vital for system observability and debugging, but writing sensitive data to logs poses several challenges and risks:
- Security and data breaches
- Compliance and legal issues - HIPAA, GDPR etc.
- Loss of customer confidence and damage to reputation
So, to mitigate these risks, the recommended approach is to redact sensitive information before it’s written to logs.
Existing Solutions
- Log parameters as key value pairs. Redact using a massive dictionary of sensitive keys. Not scalable - user_id, userId, uid.
- No guarantee of control over logging sensitive data in the application domain
- No guarantee of control at compile time
- Out of band redacting solutions
The Sanitizer
- Sanitization - a way to decide on the string representation of a piece of data (that gets logged)
- Sanitize data before logging
The talk discusses about the “Sanitizer” library we developed that makes it easy for developers to safely log data.
The library allows users to define a custom sanitizer that identifies and replaces sensitive content (e.g., PII, credentials) in log messages. This ensures:
- Logs remain informative yet safe
- Compliance with security and privacy standards
- Minimal effort to adopt in existing codebases
- Our goal is to make secure logging the default, not the exception.
Catch up with the rest of the details in the talk.