Personally Identifiable Information (PII) like names, emails, phone numbers, addresses, and payment data must not appear in plaintext logs. If logs contain PII, attackers or unauthorized staff could read sensitive data directly from log files. This creates privacy, compliance, and security risks.
Sanitizing logs means replacing PII with safe tokens or redacted values before writing to disk. Logs should contain enough context to debug issues but never expose private customer details.
# Review var/log/system.log and var/log/exception.log
grep -Ei "(customer|email|password|card|address)" var/log/*.log
# Expected: no raw email addresses, passwords, or card numbers
# Inspect module code for direct logging of user input
grep -R "logger->" app/code/*
// Instead of logging raw email
$logger->info("User email: " . $email);
// Log sanitized data
$logger->info("User email: [REDACTED]");
[2025-01-25 12:00:01] DEBUG: Login failed for john.doe@example.com with password=SuperSecret123
# Email and password written in log → FAIL
[2025-01-25 12:00:01] DEBUG: Login failed for user_id=12345 with password=[REDACTED]
# Sensitive values masked → PASS