# Email Security Hardening

> Use when hardening email infrastructure for an organization you defend. Covers mail tenant and gateway configuration, SPF, DKIM, and DMARC enforcement to reject, MTA-STS and TLS reporting, inbound attachment and link policy, outbound mail controls, mailbox and forwarding hardening, spoofing and lookalike domain protection, and configuration drift checks. Use when a new domain or tenant is set up, when spoofed mail reaches inboxes, when mail authentication reports show failures, or when an email security audit is due.

- Skill: `mizazhaider-ceh/email-security-hardening` (Agent Skill)
- Install (CLI): `npx get-skill add mizazhaider-ceh/email-security-hardening`
- Raw SKILL.md: https://api.skillmd.com/api/skills/mizazhaider-ceh/email-security-hardening/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Security
- Author: mizazhaider-ceh (https://skillmd.com/u/mizazhaider-ceh)
- Updated: 2026-11-22
- Page: https://skillmd.com/skills/mizazhaider-ceh/email-security-hardening

---


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

1. Inventory every domain and subdomain that sends mail, including
   marketing tools, ticket systems, and forgotten test domains.
2. Publish SPF, DKIM, and DMARC for each sending domain, starting
   DMARC in monitoring mode, then moving to reject.
3. Enforce transport security: MTA-STS policy, TLS reporting, and
   a requirement for TLS on inbound mail where the risk allows it.
4. Harden the gateway: block dangerous attachment types, detonate
   the rest, rewrite or verify links, and quarantine lookalike
   domains and newly registered domains.
5. Harden mailboxes: disable auto-forwarding to external addresses,
   block legacy authentication, require phishing-resistant MFA for
   mail access, and alert on mailbox rule creation.
6. Harden outbound mail: block unauthenticated sending, rate limit
   new senders, and monitor for compromised accounts sending spam.
7. Review DMARC aggregate reports weekly and fix the legitimate
   senders that fail, before tightening policy.
8. 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.

```bash
# 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.
```

```text
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.

```bash
# 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"
```

```text
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.

```python
# 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.

