Phishing defense triages the mail that gets through. This skill
hardens the mail system so less gets through in the first place,
and so your own domains cannot be spoofed by anyone else. It is
configuration work: authentication records, transport security,
gateway policy, tenant settings, and mailbox controls, checked on
a schedule because tenants drift. It is for domains and tenants
you own or are authorized to administer.
Quick Workflow
- Inventory every domain and subdomain that sends mail, including
marketing tools, ticket systems, and forgotten test domains.
- Publish SPF, DKIM, and DMARC for each sending domain, starting
DMARC in monitoring mode, then moving to reject.
- Enforce transport security: MTA-STS policy, TLS reporting, and
a requirement for TLS on inbound mail where the risk allows it.
- Harden the gateway: block dangerous attachment types, detonate
the rest, rewrite or verify links, and quarantine lookalike
domains and newly registered domains.
- Harden mailboxes: disable auto-forwarding to external addresses,
block legacy authentication, require phishing-resistant MFA for
mail access, and alert on mailbox rule creation.
- Harden outbound mail: block unauthenticated sending, rate limit
new senders, and monitor for compromised accounts sending spam.
- Review DMARC aggregate reports weekly and fix the legitimate
senders that fail, before tightening policy.
- Re-check configuration quarterly: tenants drift, new domains
appear, and a single relaxed setting can undo the rest.
1. Authentication records: SPF, DKIM, DMARC
SPF lists who may send for a domain, DKIM signs the mail so
tampering is detectable, and DMARC tells receivers what to do
when either fails, plus where to send reports. The common failure
is publishing DMARC at p=none and leaving it there forever, which
is monitoring, not enforcement. Move to reject only after the
aggregate reports show legitimate mail passing, and fix the
legitimate senders first: a marketing tool that fails DMARC will
break the day enforcement turns on, and the business will ask for
the policy to be rolled back.
# Verify authentication records for a domain before and after changes.
# Replace example.org with the domain under review.
dig +short TXT example.org | grep -i "v=spf1"
dig +short TXT _dmarc.example.org | grep -i "v=DMARC1"
# Find the DKIM selector from the mail headers, then check it, e.g. selector1.
dig +short TXT selector1._domainkey.example.org | grep -i "v=DKIM1"
# Send a test message to a mailbox you control, then inspect the
# Authentication-Results header: spf, dkim, and dmarc must all pass.
# If any fails, fix the sending service before tightening DMARC policy.
Target DMARC progression (do not skip steps):
Step 1: v=DMARC1; p=none; rua=mailto:dmarc@example.org
(monitoring, collect reports for at least 2 weeks)
Step 2: v=DMARC1; p=quarantine; pct=25, then 50, then 100
(raise pct only after legitimate senders pass)
Step 3: v=DMARC1; p=reject; rua=mailto:dmarc@example.org
(enforcement, review reports weekly thereafter)
SPF target: v=spf1 with only real senders, ending in -all (hard fail)
Non-sending domains: v=spf1 -all plus p=reject, so parked domains
cannot be spoofed either. Forgotten domains are attacker domains.
2. Transport security: MTA-STS and TLS reporting
Authentication stops spoofing. Transport security stops mail being
downgraded or read in transit. MTA-STS publishes a policy that
says "always use TLS for this domain", enforced by supporting
receivers, and TLS-RPT reports where TLS failed. Without MTA-STS,
an attacker who can interfere with the connection can strip TLS
and the mail still arrives, quietly unencrypted.
# Check MTA-STS policy publication and the TLS reporting record.
dig +short TXT _mta-sts.example.org
dig +short TXT _smtp._tls.example.org
# Fetch the policy file itself and confirm it is served over HTTPS
# with a valid certificate and mode set to enforce.
curl -s https://mta-sts.example.org/.well-known/mta-sts.txt
openssl s_client -connect mail.example.org:25 -starttls smtp \
</dev/null 2>/dev/null | grep -E "Protocol|Cipher|Verify return code"
MTA-STS policy file contents (served at the well-known path above):
version: STSv1
mode: enforce
mx: mail.example.org
max_age: 86400
TLS reporting record (_smtp._tls.example.org TXT):
v=TLSRPTv1; rua=mailto:tls-reports@example.org
3. Gateway and attachment policy
Block at the gateway what no legitimate sender should send: direct
executables, script files, and Office documents with macros from
external senders, unless a specific business case exists and is
documented. Detonate the rest in a sandbox and rewrite links so a
click goes through the gateway's check first. Quarantine, do not
deliver with a warning banner, mail from lookalike domains and
from domains registered in the last 30 days, because a banner
relies on the user noticing, and the user is the part that is
being attacked.
4. Mailbox and tenant hardening checks
The most damaging email incidents are not inbound phish, they are
compromised mailboxes with forwarding rules sending mail out and
deleting the evidence. Check these settings on a schedule, because
tenant defaults and new features quietly relax them.
# mailbox_checks.py - checklist to run against tenant audit output.
# Each check prints PASS or FAIL; any FAIL becomes a ticket, not a note.
# Replace the placeholder values with real tenant audit exports.
checks = [
("auto_forward_external_blocked", True),
("legacy_auth_blocked", True),
("mailbox_rule_creation_alerts", True),
("external_sharing_of_mail_disabled", True),
("phishing_resistant_mfa_required", True),
("dmarc_policy_is_reject", True),
]
for name, expected in checks:
actual = True # placeholder: load from tenant audit export
status = "PASS" if actual == expected else "FAIL - open a ticket"
print(f"{name:<40} {status}")
Edge cases
- Third-party senders (marketing, HR tools, ticket systems): every
one needs SPF inclusion and DKIM signing, or DMARC enforcement
will break it. Inventory first, enforce second, every time.
- Shared mailboxes and service accounts: these are the accounts
most likely to lack MFA. Give them conditional access rules and
monitor their sending volume, because attackers love them.
- Subdomains: a subdomain without SPF and DMARC is a spoofing
target even if the main domain is locked down. Publish -all and
p=reject for every non-sending subdomain.
- Encrypted attachments and password-protected files: the gateway
cannot detonate what it cannot open. Quarantine these from
external senders unless the sender is allowlisted, and train
users never to open a password that arrives in the same message.
- DMARC reports are XML and voluminous: aggregate them with a
parser or a reporting service, do not read them by hand, or
they will simply never be read.
- Emergency rollback: if enforcement breaks legitimate mail, drop
DMARC to quarantine with a low pct while fixing the sender, do
not drop to none and forget to re-tighten it.
Key references
- RFC 7208 (SPF), RFC 6376 (DKIM), RFC 7489 (DMARC).
- RFC 8461 (MTA-STS), RFC 8460 (TLS reporting).
- CISA phishing and email security guidance: https://www.cisa.gov/
- MITRE ATT&CK T1566 (Phishing) and T1137 (Office Application
Startup), the techniques gateway policy is designed to block.
- MTA-STS policy and TLS reporting are only effective when the
DNS records, the HTTPS policy file, and the MX records agree.
1---2name: email-security-hardening3description: Use when hardening email infrastructure for an organization4 you defend. Covers mail tenant and gateway configuration, SPF, DKIM,5 and DMARC enforcement to reject, MTA-STS and TLS reporting, inbound6 attachment and link policy, outbound mail controls, mailbox and7 forwarding hardening, spoofing and lookalike domain protection, and8 configuration drift checks. Use when a new domain or tenant is set9 up, when spoofed mail reaches inboxes, when mail authentication10 reports show failures, or when an email security audit is due.11version: 1.0.012domain: defensive13lifecycle: stable14last_verified: "2026-10-27"15requires: []16extends: []17relates: [phishing-defense, incident-response]18tools:19 - name: dig20 version: "9.18"21 - name: OpenSSL22 version: "3.x"23 - name: Python24 version: "3.12"25 - name: curl26 version: "8.5"27metadata:28 source: https://skillmd.com/skills/mizazhaider-ceh/email-security-hardening29---3031Phishing defense triages the mail that gets through. This skill32hardens the mail system so less gets through in the first place,33and so your own domains cannot be spoofed by anyone else. It is34configuration work: authentication records, transport security,35gateway policy, tenant settings, and mailbox controls, checked on36a schedule because tenants drift. It is for domains and tenants37you own or are authorized to administer.3839## Quick Workflow40411. Inventory every domain and subdomain that sends mail, including42 marketing tools, ticket systems, and forgotten test domains.432. Publish SPF, DKIM, and DMARC for each sending domain, starting44 DMARC in monitoring mode, then moving to reject.453. Enforce transport security: MTA-STS policy, TLS reporting, and46 a requirement for TLS on inbound mail where the risk allows it.474. Harden the gateway: block dangerous attachment types, detonate48 the rest, rewrite or verify links, and quarantine lookalike49 domains and newly registered domains.505. Harden mailboxes: disable auto-forwarding to external addresses,51 block legacy authentication, require phishing-resistant MFA for52 mail access, and alert on mailbox rule creation.536. Harden outbound mail: block unauthenticated sending, rate limit54 new senders, and monitor for compromised accounts sending spam.557. Review DMARC aggregate reports weekly and fix the legitimate56 senders that fail, before tightening policy.578. Re-check configuration quarterly: tenants drift, new domains58 appear, and a single relaxed setting can undo the rest.5960## 1. Authentication records: SPF, DKIM, DMARC6162SPF lists who may send for a domain, DKIM signs the mail so63tampering is detectable, and DMARC tells receivers what to do64when either fails, plus where to send reports. The common failure65is publishing DMARC at p=none and leaving it there forever, which66is monitoring, not enforcement. Move to reject only after the67aggregate reports show legitimate mail passing, and fix the68legitimate senders first: a marketing tool that fails DMARC will69break the day enforcement turns on, and the business will ask for70the policy to be rolled back.7172```bash73# Verify authentication records for a domain before and after changes.74# Replace example.org with the domain under review.75dig +short TXT example.org | grep -i "v=spf1"76dig +short TXT _dmarc.example.org | grep -i "v=DMARC1"77# Find the DKIM selector from the mail headers, then check it, e.g. selector1.78dig +short TXT selector1._domainkey.example.org | grep -i "v=DKIM1"7980# Send a test message to a mailbox you control, then inspect the81# Authentication-Results header: spf, dkim, and dmarc must all pass.82# If any fails, fix the sending service before tightening DMARC policy.83```8485```text86Target DMARC progression (do not skip steps):87 Step 1: v=DMARC1; p=none; rua=mailto:dmarc@example.org88 (monitoring, collect reports for at least 2 weeks)89 Step 2: v=DMARC1; p=quarantine; pct=25, then 50, then 10090 (raise pct only after legitimate senders pass)91 Step 3: v=DMARC1; p=reject; rua=mailto:dmarc@example.org92 (enforcement, review reports weekly thereafter)93 SPF target: v=spf1 with only real senders, ending in -all (hard fail)94 Non-sending domains: v=spf1 -all plus p=reject, so parked domains95 cannot be spoofed either. Forgotten domains are attacker domains.96```9798## 2. Transport security: MTA-STS and TLS reporting99100Authentication stops spoofing. Transport security stops mail being101downgraded or read in transit. MTA-STS publishes a policy that102says "always use TLS for this domain", enforced by supporting103receivers, and TLS-RPT reports where TLS failed. Without MTA-STS,104an attacker who can interfere with the connection can strip TLS105and the mail still arrives, quietly unencrypted.106107```bash108# Check MTA-STS policy publication and the TLS reporting record.109dig +short TXT _mta-sts.example.org110dig +short TXT _smtp._tls.example.org111# Fetch the policy file itself and confirm it is served over HTTPS112# with a valid certificate and mode set to enforce.113curl -s https://mta-sts.example.org/.well-known/mta-sts.txt114openssl s_client -connect mail.example.org:25 -starttls smtp \115 </dev/null 2>/dev/null | grep -E "Protocol|Cipher|Verify return code"116```117118```text119MTA-STS policy file contents (served at the well-known path above):120 version: STSv1121 mode: enforce122 mx: mail.example.org123 max_age: 86400124TLS reporting record (_smtp._tls.example.org TXT):125 v=TLSRPTv1; rua=mailto:tls-reports@example.org126```127128## 3. Gateway and attachment policy129130Block at the gateway what no legitimate sender should send: direct131executables, script files, and Office documents with macros from132external senders, unless a specific business case exists and is133documented. Detonate the rest in a sandbox and rewrite links so a134click goes through the gateway's check first. Quarantine, do not135deliver with a warning banner, mail from lookalike domains and136from domains registered in the last 30 days, because a banner137relies on the user noticing, and the user is the part that is138being attacked.139140## 4. Mailbox and tenant hardening checks141142The most damaging email incidents are not inbound phish, they are143compromised mailboxes with forwarding rules sending mail out and144deleting the evidence. Check these settings on a schedule, because145tenant defaults and new features quietly relax them.146147```python148# mailbox_checks.py - checklist to run against tenant audit output.149# Each check prints PASS or FAIL; any FAIL becomes a ticket, not a note.150# Replace the placeholder values with real tenant audit exports.151checks = [152 ("auto_forward_external_blocked", True),153 ("legacy_auth_blocked", True),154 ("mailbox_rule_creation_alerts", True),155 ("external_sharing_of_mail_disabled", True),156 ("phishing_resistant_mfa_required", True),157 ("dmarc_policy_is_reject", True),158]159for name, expected in checks:160 actual = True # placeholder: load from tenant audit export161 status = "PASS" if actual == expected else "FAIL - open a ticket"162 print(f"{name:<40} {status}")163```164165## Edge cases166167- Third-party senders (marketing, HR tools, ticket systems): every168 one needs SPF inclusion and DKIM signing, or DMARC enforcement169 will break it. Inventory first, enforce second, every time.170- Shared mailboxes and service accounts: these are the accounts171 most likely to lack MFA. Give them conditional access rules and172 monitor their sending volume, because attackers love them.173- Subdomains: a subdomain without SPF and DMARC is a spoofing174 target even if the main domain is locked down. Publish -all and175 p=reject for every non-sending subdomain.176- Encrypted attachments and password-protected files: the gateway177 cannot detonate what it cannot open. Quarantine these from178 external senders unless the sender is allowlisted, and train179 users never to open a password that arrives in the same message.180- DMARC reports are XML and voluminous: aggregate them with a181 parser or a reporting service, do not read them by hand, or182 they will simply never be read.183- Emergency rollback: if enforcement breaks legitimate mail, drop184 DMARC to quarantine with a low pct while fixing the sender, do185 not drop to none and forget to re-tighten it.186187## Key references188189- RFC 7208 (SPF), RFC 6376 (DKIM), RFC 7489 (DMARC).190- RFC 8461 (MTA-STS), RFC 8460 (TLS reporting).191- CISA phishing and email security guidance: https://www.cisa.gov/192- MITRE ATT&CK T1566 (Phishing) and T1137 (Office Application193 Startup), the techniques gateway policy is designed to block.194- MTA-STS policy and TLS reporting are only effective when the195 DNS records, the HTTPS policy file, and the MX records agree.