Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Add/Update/Fix Sender Policy Framework (SPF) TXT DNS Record #66

Open
4 tasks
jimbrig opened this issue May 11, 2024 · 0 comments
Open
4 tasks
Assignees
Labels
config Configuration Management feature New feature requests

Comments

@jimbrig
Copy link
Member

jimbrig commented May 11, 2024

Need to make our SPF record compliant and correct.

Root SPF TXT DNS Record

  • Ensure a valid TXT DNS Record for SPF exists for @.
  • Ensure the SPF TXT DNS Record doesn't violate the restriction of 10 maximum IPs:

Note

The SPF RFC says that SPF settings should not require more than 10 DNS lookups. If we manually flatten (i.e. "inline") an include, we have to remember to check back to see if the settings have changed. Humans are not good at that kind of thing.

Warning

Can only have one single SPF DNS TXT record per domain/sub-domain.

The SPF record can be build via dnscontrol's native SPF_BUILDER:

Example Usage:

D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER),
  ...
  ...
  ...
  SPF_BUILDER({
    label: "@",
    overflow: "_spf%d",  // Delete this line if you don't want big strings split.
    overhead1: "20",  // There are 20 bytes of other TXT records on this domain.  Compensate for this.
    raw: "_rawspf",  // Delete this line if the default is sufficient.
    parts: [
      "v=spf1",
      // fill in your SPF items here
      "~all"
    ],
    flatten: [
      // fill in any domains to inline.
    ]
  }),
  ...
  ...
END);

For our use-case, we send email from google, resend (amazonses), and stripe (currently):

var SPIF_RECORD = SPF_BUILDER({
  label: "@",
  parts: [
    "v=spf1",
    "include:_spf.google.com", // GSuite
    "include:amazonses.com", // Amazon SES (Resend)
    "include:stripe.com", // Stripe
    "~all"
  ],
  flatten: [
    "amazonses.com",
    "stripe.com"
  ]
});

or simply,

, TXT("@", "v=spf1 include:_spf.google.com ~all")

Note

DNSControl can optimize the SPF settings on a domain by flattening (inlining) includes and removing duplicates. DNSControl also makes it easier to document your SPF configuration.

Warning

Flattening SPF includes is risky. Only flatten an SPF setting if it is absolutely needed to bring the number of "lookups" to be less than 10. In fact, it is debatable whether or not ISPs enforce the "10 lookup rule".

For No Clocks, we initially used three "includes" domains in our SPF record:

"v=spf1 include:_spf.google.com amazonses.com stripe.com ~all"

however, this resulted in more than the maximum allowed 10 individual IPs across those three domains.

Therefore, we should only implement the primary _spf.google.com include:

"v=spf1 include:_spf.google.com ~all"
// TXT Records - SPF
, TXT("@", "v=spf1 include:_spf.google.com ~all")
, TXT("send", "v=spf1 include:amazonses.com ~all")
  • Add any necessary includes to the record
  • Publish and validate record
@jimbrig jimbrig added config Configuration Management documentation Improvements or additions to documentation enhancement New feature or request feature New feature requests refactor Code refactoring and cleanup release Indicates preparations for a new release setup Setup & Initialization labels May 11, 2024
@jimbrig jimbrig self-assigned this May 11, 2024
@jimbrig jimbrig changed the title [Milestone]: Domain (noclocks.dev) Email Health Compliant [Feature]: Add/Update/Fix Sender Policy Framework (SPF) TXT DNS Record May 11, 2024
@jimbrig jimbrig removed documentation Improvements or additions to documentation enhancement New feature or request refactor Code refactoring and cleanup release Indicates preparations for a new release setup Setup & Initialization labels May 11, 2024
jimbrig added a commit that referenced this issue May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config Configuration Management feature New feature requests
Projects
Status: In Progress
Status: Ready
Development

No branches or pull requests

1 participant