Why this matters
HIPAA technical safeguards require protecting ePHI at rest with strong, auditable encryption and key management.
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.
HIPAA technical safeguards require protecting ePHI at rest with strong, auditable encryption and key management.
Side-by-side examples engineers can pattern-match during review.
db.Exec("INSERT INTO records (patient_id, note) VALUES (?, ?)", id, note) // plaintext ePHIct, kid := kms.Encrypt(ctx, dataKeyAlias, ephiBytes) ; db.Exec("INSERT INTO records (patient_id, blob, kid) VALUES (?,?,?)", id, ct, kid)db.Save(Record{Note: note}) // plaintextcipher, kid := kms.Encrypt(ctx, "alias/phi-data", ephi)
db.Save(Record{Blob: cipher, KMSKeyID: kid})From the same buckets as this rule.
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.