Most developers and IT teams have seen a suspicious invoice or executive wire-change request where the mailbox shows spf=pass and dkim=pass, yet the message is still a Business Email Compromise (BEC) spoof.

Understanding why requires separating the SMTP envelope (RFC 5321) from the message header (RFC 5322)—and inspecting the raw headers without uploading confidential corporate .eml metadata to a remote third-party web parser.

1. Envelope vs. Header: Where Spoofing Hides

SMTP carries two separate sender identities:

  • Return-Path (MAIL FROM envelope): Evaluated by SPF (RFC 7208) against the connecting server's IP.
  • From header (RFC 5322): Displayed prominently in the user's inbox.
  • Reply-To header (RFC 5322): Silently redirects replies when the recipient clicks Reply.

An attacker who controls mail-dispatch.example.net can publish a valid SPF record, sign the message with their own DKIM key (header.d=mail-dispatch.example.net), and still put billing@trusted-vendor.example.com inside the visible From header:

Authentication-Results: mx-inbound.acme-buyer.example.com; spf=pass smtp.mailfrom=bounce@mail-dispatch.example.net; dkim=pass header.d=mail-dispatch.example.net header.s=s1; dmarc=fail (p=REJECT) header.from=trusted-vendor.example.com; arc=none 

SPF passed. DKIM passed. Yet DMARC (RFC 7489) failed because neither the SPF envelope domain nor the DKIM header.d domain aligned with the organizational domain in the visible From header.

Check What Passes Alone? What Closes the Spoofing Gap?
SPF (RFC 7208) Connecting IP is allowed by Return-Path domain DMARC SPF alignment (Return-Path matches From)
DKIM (RFC 6376) Body/headers match public key at header.d DMARC DKIM alignment (header.d matches From)
Reply-To Check Not evaluated by SPF/DKIM/DMARC at all Explicit domain comparison between From and Reply-To

2. Reading Received: Hops From the Trust Boundary Downward

Every mail relay prepends its Received: header to the top of the message, so raw headers read newest-first (top) to claimed origin (bottom). Because an attacker can fabricate fake Received: lines before sending a message, start at the topmost Received: ... by <your-own-mx> header and trace downward:

  1. Unfold multi-line RFC 5322 headers first (/\r?\n[ \t]+/g -> " ") before parsing Authentication-Results or Received timestamps.
  2. Decode RFC 2047 MIME encoded words (=?UTF-8?B?...?= and =?UTF-8?Q?...?=) inside From and Subject to expose hidden Unicode spoofing or urgent invoice lures.
  3. Convert hop timestamps to UTC and inspect hop-to-hop deltas: large negative clock skew or multi-minute relay delays between obscure hosts often signal forged origin headers or spam queues.
  4. Defang extracted IPs and URLs (hxxps[://], [.]) before pasting indicators into tickets or team chat so nobody—and no link-preview bot—clicks a live phishing URL.

3. Run the Zero-Upload Browser Analyzer

Rather than pasting sensitive corporate headers into a server-backed tool, I put together a clean-room, zero-backend client-side analyzer inspired by GCHQ CyberChef's local-processing approach:

  • 100% local execution (~8.6 KB gzipped ES2020, zero fetch/XHR calls — verifiable in DevTools Network tab)
  • Unfolds RFC 5322 headers, decodes RFC 2047 Base64/Quoted-Printable subjects, evaluates SPF/DKIM/DMARC/ARC + Reply-To spoofing, classifies hop IPs (RFC 1918 / RFC 6598 CGNAT / RFC 4193), and exports CSV/JSON reports with 1-click Defang / Refang IOC toggling

Try the live tool & full RFC guide: Offline Email Header, SPF/DKIM/DMARC & Phishing Hop Analyzer

If you also work with cryptographic benchmarks or automation pipelines, our open CC-BY-4.0 JSON datasets are live with CORS: * at:

Written and prepared by Kshitij Gupta. Originally published at The Infosiast.