ADR-003: Keep SendGrid credentials and message data within the delivery boundary
SendGrid credentials are runtime secrets, while email addresses and message content are restricted to the components that require them for delivery and support.
1. Context & Problem
Integrating with SendGridSystemv1.0.0SendGridExternal email delivery platform used by BookWorm to submit rendered transactional emails over authenticated SMTP. Ownerplatform-engineering-teamDiagramOpen docs requires sensitive provider credentials and processes personal customer data, including email addresses, subject lines, and full message bodies.
If credentials or message contents leak into source repositories, architecture documentation, background job payloads, or routine operational logs, the blast radius of a breach or accidental exposure grows dramatically. Because notifications pass through both local storage and external delivery calls, security and privacy boundaries must govern stored records, active transmissions, and diagnostic telemetry alike.
2. Business Value
- Reduced breach and compliance risk: Keeping personal email addresses and message contents out of routine logs and shared telemetry limits exposure of sensitive customer data.
- Safer, faster credential rotation: Managing provider credentials purely through runtime configuration allows operations teams to rotate keys without editing code or documentation.
- Least-privilege operations: Separating access to credentials, stored messages, and operational metrics ensures support and monitoring teams see only what they need to do their jobs.
3. How It Works
BookWorm enforces a strict boundary around both authentication secrets and customer message data:
- Runtime-only credentials: Authentication secrets for SendGridSystemv1.0.0SendGridExternal email delivery platform used by BookWorm to submit rendered transactional emails over authenticated SMTP. Ownerplatform-engineering-teamDiagramOpen docs are injected strictly through secure runtime configuration and never appear in source code, catalog documentation, or logs.
- Need-to-know content access: Only the Notification SystemSystemv1.0.0Notification SystemInternal platform system that consumes order commands, renders email templates, and submits messages over SMTP. Ownerplatform-engineering-teamDiagramOpen docs and the SendGrid APIServicev1.0.0SendGrid APIExternal SMTP email delivery provider used by BookWorm to submit rendered order notification emails over authenticated S...Ownerplatform-engineering-teamDiagramOpen docs integration may access recipient addresses, sender details, and message content, and only to deliver messages or perform authorized support investigations.
- Identifier-first telemetry: Routine logs, scheduler messages, and delivery records rely on stable notification identifiers, provider status, error categories, and correlation metadata instead of full message content or recipient addresses.
- Controlled retention and diagnostics: Any diagnostic capture of sensitive fields must be explicitly authorized, access-restricted, and governed by platform retention rules.
4. Trade-offs & Lessons Learned
- Extra step for detailed troubleshooting: Excluding email addresses and bodies from standard logs makes routine telemetry safer to share, but requires support operators to look up protected notification records by their stable identifier when deep inspection is needed.
- Internal storage remains in scope: Protecting the external provider connection is not enough; BookWorm’s own outbox records, databases, and logs hold rendered messages and must be protected with least-privilege access controls and secret scanning.
- Retention and logging remediation needed: Documenting a security policy does not automatically make existing code compliant. Current cleanup behavior lacks a formal privacy or audit retention period, and existing resend and failure logging paths still record sensitive details that must be remediated.
- Alternatives rejected:
- Storing credentials in source code or durable scheduler metadata: Increases exposure risk and complicates key rotation.
- Copying full message content into logs and events: Spreads personal data across too many downstream monitoring systems.
- Treating the external provider as the sole confidential boundary: Ignores local storage, telemetry, and internal support surfaces.
5. Technical Reference
Security & Access Surfaces
- Applies to: SendGridSystemv1.0.0SendGridExternal email delivery platform used by BookWorm to submit rendered transactional emails over authenticated SMTP. Ownerplatform-engineering-teamDiagramOpen docs, Notification SystemSystemv1.0.0Notification SystemInternal platform system that consumes order commands, renders email templates, and submits messages over SMTP. Ownerplatform-engineering-teamDiagramOpen docs, SendGrid APIServicev1.0.0SendGrid APIExternal SMTP email delivery provider used by BookWorm to submit rendered order notification emails over authenticated S...Ownerplatform-engineering-teamDiagramOpen docs.
- Secret injection: Provider credentials must be supplied via runtime secret configuration—never in source control, EventCatalog documentation, logs, or durable Quartz job metadata.
- Distinct least-privilege surfaces:
- Provider API credentials
- Database credentials
- Notification / outbox records (confidential while pending and after submission until cleanup)
- Operational telemetry and routine logs
Known Remediation Gaps
- Retention policy gap: Current outbox cleanup behavior does not define a formal privacy retention period or audit-retention policy.
- Sensitive logging gap: Current Notification documentation identifies resend logs containing recipient addresses and SMTP failure logs containing recipients and subjects. These existing paths require remediation and must not be treated as compliant solely because this ADR is accepted.