The crash came at 2:43 a.m. The logs bloomed with errors, stack traces, and something worse—names, emails, phone numbers. PII in plaintext, sitting in production for anyone with access to see.
Masking PII in production logs is not optional. It is a core requirement for security, compliance, and trust. In fast-moving systems, every request, response, and debug trace can carry sensitive data. Without controls in place, these details leak into logs where they persist, searchable and exposed.
Mosh, the modern shell for remote sessions, is often part of workflows where logs flow from production services in real time. If any service connected to Mosh emits unfiltered output, private data can cross the session and land in persistent log stores. The risk compounds when logs are aggregated, backed up, and shipped to third-party observability tools.
The right approach is to design a masking layer before the log write. This means detecting patterns for emails, phone numbers, credit card numbers, government IDs, and any other regulated PII. Regex matching is a start but too brittle for scale. Production workloads need streaming processors intercepting and sanitizing data before it leaves the process. This can be done inside the application logger, as middleware, or at the edge of a logging pipeline.