Security Engineering / Fundamentals / Email
Fundamental 08

Email &
message security SMTP was designed in 1982 with no authentication whatsoever. Every control since — SPF, DKIM, DMARC, ARC, BIMI — is a patch bolted onto that. Understand the original protocol and the patches stop being a checklist and start being a system you can reason about.

Google Workspace contextfeeds → Abnormal Security5 tiers
Tier 0 · Groundthe protocol

How a message actually moves

Module 0.1

SMTP, and the two "from" addresses

The single most important concept on this page

SMTP has two layers, and they carry different sender addresses. Every authentication mechanism below depends on knowing which one it checks.

┌─ ENVELOPE (the SMTP conversation) ──────────────┐ │ MAIL FROM: bounces@mailer.acme.com │ ← envelope sender │ RCPT TO: jdoe@example.com │ aka Return-Path │ DATA │ SPF checks THIS │ ┌─ MESSAGE (headers + body) ─────────────────┐ │ │ │ From: "Acme Billing" <billing@acme.com> │ │ ← header From │ │ Reply-To: ap@acme-invoices.net │ │ the user SEES this │ │ Subject: Invoice 4471 │ │ DMARC aligns THIS │ │ ...body... │ │ │ └────────────────────────────────────────────┘ │ └─────────────────────────────────────────────────┘

The envelope is the addressed sack the postal service reads; the message headers are the letterhead inside, which the sender writes freely. Nothing in SMTP prevents me typing any From address I like. That is not a bug being fixed — it is the protocol.

A raw SMTP conversation

220 mx.google.com ESMTP ready
EHLO mailer.acme.com
250-mx.google.com at your service
250-STARTTLS
STARTTLS                       upgrade to TLS — opportunistic!
MAIL FROM:<bounces@mailer.acme.com>    envelope sender → SPF
250 2.1.0 OK
RCPT TO:<jdoe@example.com>
250 2.1.5 OK
DATA
From: "Acme Billing" <billing@acme.com>      header From → DMARC
Subject: Invoice 4471
.
250 2.0.0 OK  queued as 4A2F...
STARTTLS is opportunistic — if the receiving server does not offer it, mail is sent in cleartext, and an attacker in path can strip the offer. MTA-STS (a policy published over HTTPS) and DANE fix this by declaring "TLS is mandatory for my domain"; TLS-RPT reports failures. Publishing MTA-STS is a cheap, visible maturity win.
Module 0.2

SMTP vs IMAP vs POP3 — and why it matters for compromise

Sending, syncing, downloading
ProtocolJobPortsSecurity relevance
SMTPServer-to-server transport25 (MTA), 587 submission, 465 implicit TLSPort 25 outbound from workstations should be blocked
IMAPClient syncs with the server; mail stays143 / 993Legacy IMAP often bypasses MFA — a favourite for account takeover
POP3Client downloads and usually deletes110 / 995Attackers enable it to silently exfiltrate an entire mailbox
Workspace check: after any account compromise, look at whether IMAP/POP access was enabled, whether an app password was created, and whether delegation or forwarding was added. These are persistence mechanisms that survive a password reset and are invisible in the web UI unless you go looking.
Tier 1 · Mechanicsauthentication

SPF, DKIM, DMARC — properly

Module 1.1

SPF — who may send for this domain

An IP allow-list in DNS, with a lookup budget
# dig acme.com TXT
v=spf1 include:_spf.google.com include:sendgrid.net ip4:203.0.113.10 ~all
MechanismMeaning
include:Also accept whatever that domain's SPF authorises (recursive)
ip4: / ip6:Literal address or range
mx: / a:The domain's MX or A records may send
-allHard fail — reject anything else
~allSoft fail — accept but mark
?allNeutral — effectively no policy

SPF checks the envelope sender (Return-Path), not the From header the user sees. This is the crucial limitation: an attacker can pass SPF perfectly for their own domain while displaying billing@acme.com in From. SPF alone stops nothing that a user would notice.

Two operational traps

  • The 10-lookup limit. SPF evaluation permits a maximum of 10 DNS lookups; exceed it and the result is permerror, which many receivers treat as a failure. Every new SaaS that sends on your behalf adds an include:. Audit this regularly and use flattening services carefully.
  • SPF breaks on forwarding. A forwarded message arrives from the forwarder's IP, which is not in your SPF. This is exactly what ARC exists to repair.
Module 1.2

DKIM — a signature over the message

Survives forwarding; proves integrity, not intent

The sending server signs selected headers and the body with a private key; the public key lives in DNS at <selector>._domainkey.<domain>. The receiver fetches it and verifies.

DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
  d=acme.com;            the signing domain — DMARC aligns on this
  s=selector1;           which key to fetch
  h=from:to:subject:date;  headers covered by the signature
  bh=...; b=...          body hash; signature

Because the signature travels with the message, DKIM survives forwarding as long as nothing modifies the signed headers or body (mailing lists that append footers break it).

DKIM proves the message left the claimed domain unmodified. It does not prove the content is honest. A compromised account at a real supplier sends perfectly DKIM-signed fraud. This is precisely the gap that behavioural email security exists to fill.
Module 1.3

DMARC — alignment and policy

The piece that finally protects the visible From
# dig _dmarc.acme.com TXT
v=DMARC1; p=reject; sp=reject; adkim=s; aspf=s; pct=100;
rua=mailto:dmarc@acme.com; ruf=mailto:forensic@acme.com

DMARC does two things SPF and DKIM cannot:

  1. Alignment — it requires the domain in the visible From header to match the domain that passed SPF (the Return-Path) or the DKIM d=. Passing SPF for attacker.net no longer helps if From says acme.com.
  2. Policy and reporting — tells receivers what to do on failure, and sends you aggregate reports about every source sending as your domain.
TagValuesMeaning
p=none / quarantine / rejectPolicy for your domain
sp=samePolicy for subdomains — set it, or subdomains are a gap
adkim= / aspf=r (relaxed) / s (strict)Relaxed allows organisational-domain match, e.g. mail.acme.com
pct=0–100Percentage of failing mail the policy applies to — the rollout dial
rua= / ruf=mailtoAggregate (daily XML) and forensic reports

Rollout that does not break your own mail

1Publish p=none with rua=. Collect reports for a few weeks.
2Inventory every legitimate sender in those reports — marketing, invoicing, HR tools, monitoring. Fix their SPF/DKIM.
3Move to p=quarantine with pct= ramping upward.
4Reach p=reject; sp=reject, and publish reject on parked domains too — those are the ones attackers love.
What DMARC does not do: it protects your domain from being spoofed. It does nothing about lookalike domains (acrne.com, acme-invoices.net), display-name spoofing, compromised legitimate senders, or a Reply-To pointing somewhere else entirely. Those are the majority of real BEC attempts, which is why DMARC at reject is the floor rather than the answer.
Module 1.4

ARC, BIMI and the rest of the alphabet

Repairing forwarding, and the vanity layer
  • ARC (Authenticated Received Chain) — each intermediary that modifies a message stamps the original authentication results and signs them, so a final receiver can see "this failed SPF, but Google verified it passed before forwarding". Google Workspace both applies and honours ARC, which is why mailing-list mail from your domain usually still lands.
  • BIMI — displays your brand logo in supporting clients, gated on DMARC at enforcement (and usually a VMC certificate). Useful mainly as an internal lever to justify finishing the DMARC project.
  • MTA-STS / DANE / TLS-RPT — enforce transport encryption between servers, as above.
Module 1.5

Reading headers like an analyst

Line by line, bottom to top

In Gmail: ⋮ → Show original gives the full source plus Google's own SPF/DKIM/DMARC verdicts. Read Received: headers bottom to top — the bottom one is the earliest hop, and everything below the first server you trust can be forged.

Return-Path: <bounce@mailer-xyz.top>        envelope sender — mismatch is a flag
Received: from mailer-xyz.top (198.51.100.9)
   by mx.google.com ... Tue, 12 Aug 2025 09:14:02
Authentication-Results: mx.google.com;
   spf=pass (google.com: domain of bounce@mailer-xyz.top designates
        198.51.100.9 as permitted sender);
   dkim=pass header.d=mailer-xyz.top;
   dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=acme.com
From: "Acme Billing" <billing@acme.com>
Reply-To: ap@acme-invoices.net              the payload
Message-ID: <...@mailer-xyz.top>
X-Originating-IP: ...

Read that block properly and the story is complete: SPF and DKIM both pass — for the attacker's own domain — while DMARC fails because the visible From claims acme.com. The Reply-To sends any response to a domain the attacker controls. "SPF passed" in isolation means almost nothing.

Triage checklist for a reported phish

  1. Compare Return-Path, From and Reply-To. Any divergence is a story.
  2. Read Authentication-Results — specifically the DMARC verdict and header.from.
  3. Check the sending domain's age (WHOIS creation date) — days-old domains are a strong signal.
  4. Expand links without clicking; look for redirectors, punycode and lookalike hosts.
  5. Search the tenant for other recipients of the same campaign; remediate in bulk.
  6. If anyone interacted: treat it as identity compromise — revoke sessions, check rules, forwarding, delegation, app passwords and OAuth grants.
Drill 1

A message shows spf=pass, dkim=pass, dmarc=fail, with From: finance@example.com. What happened?

Alignment failure. SPF and DKIM passed for the sender's own domain; DMARC compares those against the visible From and finds a mismatch. The immediate question is what the org's DMARC policy is — with p=reject this message should never have been delivered, so either the policy is still none, or it arrived at a receiver that ignores DMARC, or an internal relay is trusted and skipping the check.
Tier 2 · OperateGoogle Workspace

Gmail administration in practice

Module 2.1

The Workspace controls that matter

Where to look in the admin console
  • Email log search (Reporting → Email Log Search) — trace delivery of a specific message by recipient, subject or Message-ID; shows the actual disposition.
  • Security investigation tool — bulk search across Gmail, Drive, devices and logins; the place you remediate a campaign (delete from all mailboxes, mark as phishing).
  • Gmail safety settings — attachment protections, link and external image protection, spoofing and authentication warnings, and the banner for external senders.
  • Routing and compliance rules — content compliance, objectionable content, and the routing rules that matter most for security architecture: whether a third-party gateway sits before or after Google.
  • Allowlists — the inbound gateway and IP allow-lists are the most dangerous settings in the console. An over-broad entry silently disables spam and authentication checks for whoever is on it.
  • Alert centre — Google's own suspicious-login, phishing and malware alerts; make sure they route somewhere staffed.
The classic Workspace misconfiguration: a "bypass spam filter" rule created years ago for a marketing platform, still matching, still trusted. Review inbound gateway settings, allow-lists and any content compliance rule with an exception at least annually — and check them first when something obviously bad gets delivered.
Module 2.2

BEC anatomy — the attack that ignores your filters

No payload, no link, no malware
1Reconnaissance — LinkedIn, the website, Companies House: who signs off payments, who the suppliers are.
2Access or impersonation — either compromise a real supplier mailbox (then everything authenticates perfectly), or register a lookalike domain.
3Thread insertion — reply into an existing invoice thread, or a "quick favour" from the CFO's display name to a junior in finance.
4The ask — updated bank details, urgent payment, gift cards, or payroll redirection.
5Concealment — inbox rules moving replies to an obscure folder so the real person never notices.

Note what none of these steps involve: an attachment, a malicious URL, or a signature to match. Content filtering has nothing to grab hold of. What does catch it is behaviour — this sender has never emailed this recipient, the reply-to differs from the from, the domain was registered eleven days ago, the tone and timing are anomalous, and finance is being asked to change payment details.

Process beats technology here: out-of-band verification for any bank-detail change, on a phone number held on file rather than one in the email, plus dual authorisation for payments above a threshold. Every FinTech that has lost money to BEC had a filter; what they lacked was that callback rule.
Tier 3 · Engineerarchitecture

Designing mail defence

Module 3.1

Gateway vs API deployment

The decision that shapes everything downstream
SEG (gateway, MX-record)API-integrated
PositionIn front of Google — MX points at itBeside Google — OAuth into the tenant
Blocks pre-deliveryYesNo — remediates seconds after delivery
Sees internal mailNo (never traverses it)Yes — catches lateral phishing
Deployment riskMX change; a failure stops mailVery low; no mail-flow change
Signals availableThe message itselfMessage + full tenant history and behaviour

The modern pattern — and the one Abnormal implements — is to let Google's native filtering handle the volume of commodity spam and malware, then layer an API-integrated behavioural product that reads the whole tenant to catch what content inspection structurally cannot: BEC, account takeover, vendor fraud and internal lateral phishing.

Layering question to answer explicitly: which system is authoritative for quarantine, and where do users report suspicious mail? Two quarantines with two release processes is a reliable source of both user frustration and missed detections.

Module 3.2

Email signals worth sending to the SIEM

Correlation beyond the mail tool
  • Message delivered/quarantined events with sender, recipient, subject hash, verdict and URLs.
  • Mail rule creation, forwarding and delegation changes — the single highest-value Workspace audit event for account takeover.
  • OAuth grant events for high-risk scopes.
  • Suspicious login events from Workspace correlated with proxy and EDR data.

The correlations that earn their keep: phish delivered → user clicked (proxy log) → login from new ASN (IdP) → inbox rule created (Workspace). Any one alone is ambiguous; together they are an incident, and building that chain is exactly what a SIEM is for.

Referencesearchable

Glossary