Skip to content

fix(privacy): avoid logging raw email payloads, BCC recipients, and unredacted PII in smtp-server and web logs (CWE-532) #533

Open

Description

@halilyilmz

Summary

While auditing log hygiene across useSend, I noticed a few places where full email bodies, attachments, BCC lists, and plaintext recipient email addresses are written directly to production logs without redaction (CWE-532 / GDPR Art. 5(1)(c) data minimization):

1. Full raw email payload & attachments dumped on SMTP relay errors (apps/smtp-server)

  • apps/smtp-server/src/server.ts:41-45: When the useSend API returns any non-2xx response (e.g. 400, 429 rate limit, or 500), console.error prints the full serialized emailDataText JSON:
    console.error(
      "useSend API error response: error:",
      JSON.stringify(errorData, null, 4),
      `\nemail data: ${emailDataText}`,
    );
    emailDataText contains from, to, cc, bcc, subject, full text/html bodies (including transactional OTPs, password-reset links, or sensitive customer messages), and base64-encoded attachments.
  • apps/smtp-server/src/server.ts:123: Every successful SMTP relay logs plaintext recipient addresses:
    .then(() => console.log("Email sent successfully to: ", emailObject.to))

2. Unredacted Pino logging of recipient emails & BCC arrays (apps/web)

  • apps/web/src/server/logger/log.ts:11-23: rootLogger initializes pino(...) without a redact configuration, while several production services log raw recipient addresses and BCC lists:
    • apps/web/src/server/service/campaign-service.ts:1312-1319, 1363-1384 — logs contactEmail, originalCc, filteredCc, originalBcc, and filteredBcc
    • apps/web/src/server/service/email-service.ts:221-240, 526-536 — logs originalCc, filteredCc, originalBcc, filteredBcc, and suppressedEmails (to + suppressedAddresses)
    • apps/web/src/server/service/contact-queue-service.ts:106-120 — logs contactEmail: contact.email on every queued contact job (processing, success, and failure)
    • apps/web/src/server/service/suppression-service.ts:72-81, 109-116 & apps/web/src/server/aws/ses.ts:330-344 — logs plaintext email

3. Leftover client-side debug log on login

  • apps/web/src/app/login/login-page.tsx:124: console.log("email", email); inside onOTPSubmit.

Proposed Fix

  1. apps/smtp-server/src/server.ts: Log only non-PII diagnostic metadata (HTTP status, recipient count, attachment count) instead of emailDataText and emailObject.to.
  2. apps/web/src/app/login/login-page.tsx: Remove the leftover console.log("email", email).
  3. apps/web/src/server/logger/log.ts & affected services: Either configure Pino redact paths for PII/recipient fields (email, contactEmail, originalBcc, filteredBcc, originalCc, filteredCc, suppressedEmails, etc.) and/or replace raw address arrays with counts and IDs (campaignId, teamId, suppressedCount).

If you'd like this addressed and can confirm whether you prefer central Pino redact, logging counts/IDs instead of email arrays, or both, I'd be happy to open a clean PR with tests.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions