Skip to content

Dmarc dkim verification - #2802

Open
oliver-gordon wants to merge 8 commits into
masterfrom
dmarc_dkim_verification
Open

oliver-gordon wants to merge 8 commits into
masterfrom
dmarc_dkim_verification

Conversation

@oliver-gordon

Copy link
Copy Markdown
Collaborator

Introduce validation checks for dmarc and dkim, use the same issue counter as mx record checks to trigger notifications. This allows us to avoid new columns and a migration. Two new email templates for user notifications

Comment thread tasks/check_custom_domains.py Outdated
Comment on lines +128 to +130
if custom_domain.is_sl_subdomain:
dkim_ok = True
dmarc_ok = True

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id move this to the top and if it's is_sl_subdomain return like the custom_domain.user.disabled. There are some domains with whacky states and I'd avoid messing with those for now.

Comment thread tasks/check_custom_domains.py Outdated
dmarc_ok = validator.validate_dmarc_records(custom_domain).success

domain_dns_url = f"{config.URL}/dashboard/domains/{custom_domain.id}/dns"
provider = "Proton" if user.has_used_alias_from_partner() else "SimpleLogin"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably we should check whether the domain has created via partner, as a user can have domains added via Pass or via SL

@oliver-gordon
oliver-gordon force-pushed the dmarc_dkim_verification branch from c96ba41 to fff0b82 Compare October 6, 2026 14:17
The check_custom_domains cron alerted every MX-verified domain whose DKIM
or DMARC records were missing, including users who never configured them,
and called the mutating validators, which clear dkim_verified/dmarc_verified
on a single transient DNS failure (disabling outbound DKIM signing).

- Snapshot dkim_verified/dmarc_verified before any mutation; only count
  failures and alert when the record was previously verified.
- Add read-only check_dkim_records/check_dmarc_record to CustomDomainValidation
  and use them in the cron; flags now only flip once the failure threshold is
  reached and the alert actually went out.
- Apply the legacy single dkim._domainkey compatibility rule to the cron check
  so pre-multi-key domains are neither alerted nor de-verified.
- Rate-limit alerts per domain (domain in the SentAlert key) so a second broken
  domain is not silenced by the first one's alert; if the alert is rate-limited,
  keep counting instead of de-verifying without notice.
- validate_dmarc_records only writes the audit log entry when the flag flips.
- Tests drive the flow through InMemoryDNSClient instead of patching validators.
Otherwise a stale *_nb_failed_checks_updated_at would throttle the counter
for up to a day if the user re-verifies the records right after being alerted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants