Why this matters
HIPAA requires safeguarding PHI; logging PHI creates uncontrolled copies and disclosure risk.
Never write Protected Health Information (PHI/ePHI) to logs. Redact fields like name, SSN, MRN, DOB, address, diagnoses, and lab results; store only non-identifying metadata and a stable request trace id. If logging is required for troubleshooting, replace values with consistent tokens and record access separately in the audit log.
HIPAA requires safeguarding PHI; logging PHI creates uncontrolled copies and disclosure risk.
Side-by-side examples engineers can pattern-match during review.
log.info("GET /patients/{id}", { patientName, ssn, mrn, dob, diagnosis })log.info("GET /patients/{id}", { traceId, route:"/patients/:id", status:200 }) // audit_log.write({ action:"READ_PHI", subject: userId, resource: patientId, purpose: header.Purpose-Of-Use })logger.info({ mrn, diagnosis })logger.info({ traceId, status }); /* audit_log.write({action:"READ_PHI",subject:userId,resource:patientId}) */From the same buckets as this rule.
Before persisting ePHI, encrypt using a data key protected by a Key Management Service (KMS). Use authenticated encryption (AES-256-GCM or equivalent), rotate keys, and store the key id and algorithm with the record.