Forensics Beginner Email Analysis / Phishing / Threat Intel

Email Header Analysis

A practical guide to reading and analysing email headers � tracing the delivery path, validating SPF, DKIM, and DMARC, identifying spoofing attempts, and extracting IOCs from suspicious emails.

12 min read Email Security Blue Team / SOC

// What are Email Headers?

Email headers are metadata prepended to every email. They contain the complete delivery path, sender information, authentication results, timestamps, and technical details about the message. The email client hides them by default � but for security analysis, they are essential.

Headers are added at each hop as the email travels from the sender's mail client ? sender's mail server ? intermediate relays ? recipient's mail server ? recipient's inbox. Each server prepends its own Received: header, building a chain from destination back to origin.

How to view headers

ClientHow to access headers
Outlook (desktop)File ? Properties ? Internet headers
Outlook (web)More actions (�) ? View message source
GmailThree dots menu ? Show original
Apple MailView ? Message ? All Headers
ThunderbirdView ? Message Source (Ctrl+U)

// The Received Chain

The most important part of the header for tracing email origin. Each mail server adds a Received: header at the top as the message passes through. Because each new header is prepended, the chain reads bottom to top � the bottom entry is where the email originated, the top entry is where it was delivered.

Received headers can be forged � but only up to the first server your organisation controls. The topmost Received: header added by your own mail gateway is trustworthy; everything below it could have been injected by the sender.

Anatomy of a Received header

Email Header
Received: from mail.evil.com (mail.evil.com [185.220.101.42])
        by mx.victim.org (Postfix) with ESMTP id A3F2B1C4D5
        for <user@victim.org>; Mon, 15 Jan 2024 09:32:11 +0000 (UTC)
PartMeaning
from mail.evil.comHostname the sending server announced (HELO/EHLO) � can be faked
(mail.evil.com [185.220.101.42])Reverse DNS lookup of the connecting IP � more reliable than the announced name
[185.220.101.42]The actual connecting IP � this is what to check against threat intel
by mx.victim.orgThe receiving server � in this case, your organisation's MX server
TimestampWhen this hop occurred � compare across hops to identify unusual delays

// Key Header Fields

HeaderWhat it containsNotes
From:Display name and address the sender chose � what the user sees in their email clientEasily faked � this is the primary spoofing vector
Reply-To:Address replies will be sent to if different from FromPhishers use this to redirect replies to attacker-controlled inbox
Return-Path:Address for bounce messages (envelope sender)Should match the From domain in legitimate email; mismatch = spoofing signal
Envelope-From (MAIL FROM)The sender address declared in the SMTP envelope � not a message header itself, but visible as Return-Path: in delivered mailWhat SPF validates against � can differ from the From: header
Message-ID:Unique identifier for the message, assigned by the sending serverFormat is <random@sending-domain> � domain should match sender
X-Originating-IP:IP address of the user who submitted the email to the mail serverAdded by some providers (Outlook, Yahoo) � reveals sender's real IP
X-Mailer:Email client or library used to send the messagePhishing tools and malware often leave identifiable strings here
MIME-Version:MIME protocol version � always 1.0Check Content-Type for attachments and multipart structures
Date:Timestamp the sender's client setCompare against Received timestamps � large discrepancies are suspicious

// SPF � Sender Policy Framework

SPF is a DNS TXT record that lists the IP addresses and mail servers authorised to send email on behalf of a domain. When a receiving server gets an email, it checks whether the sending IP is listed in the sender domain's SPF record.

SPF record example

DNS TXT record
v=spf1 include:_spf.google.com include:mailgun.org ip4:203.0.113.10 -all
MechanismMeaning
v=spf1SPF version � always starts with this
include:_spf.google.comAuthorise all IPs listed in Google's SPF record (for G Suite users)
ip4:203.0.113.10Explicitly authorise this specific IP
-allHard fail � any IP not listed should be rejected. ~all = soft fail (mark as spam), ?all = neutral

SPF results

ResultMeaning
passSending IP is authorised � legitimate
failSending IP is explicitly not authorised � spoofing likely
softfailNot authorised but domain policy says to accept and mark
neutralDomain makes no assertion � treat as unauthenticated
noneNo SPF record found for the domain
temperrorDNS lookup failed temporarily � retry
permerrorSPF record is malformed

// DKIM � DomainKeys Identified Mail

DKIM adds a cryptographic signature to outgoing emails. The sending server signs the email headers and body with a private key. The public key is published in DNS, and receiving servers use it to verify the signature � proving the email was sent by a server with access to the domain's private key and hasn't been modified in transit.

DKIM-Signature header

Email Header
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=example.com; s=selector1;
        h=from:to:subject:date:message-id;
        bh=2jUSOH9NhtIezdxbLPkV5MrHqkRs8/4+MNaJ2SY6TdU=;
        b=AuUoFEfDxTDkHlLXSZEpZj79LICEpsvy98LdGvqD...
TagMeaning
d=example.comThe signing domain � should match or align with the From: domain
s=selector1Selector � identifies which public key in DNS to use (selector1._domainkey.example.com)
h=from:to:subject...Headers that were signed � if these are modified in transit, verification fails
bh=...Hash of the email body � body tampering detected here
b=...The actual cryptographic signature

DKIM pass means the email was signed by the stated domain and hasn't been modified. However, it does not mean the From: address is legitimate � an attacker can register evil.com, set up DKIM for it, and send spoofed-looking emails that pass DKIM. This is where DMARC comes in.

// DMARC � Domain-based Message Authentication

DMARC ties SPF and DKIM together and adds a policy telling receiving servers what to do if checks fail. It requires alignment � the domain in the From: header must align with the domain used in SPF and/or DKIM. This closes the gap where SPF and DKIM could pass even for spoofed From: addresses.

DMARC record example

DNS TXT record � _dmarc.example.com
v=DMARC1; p=reject; rua=mailto:dmarc-reports@example.com; ruf=mailto:dmarc-fail@example.com; pct=100; adkim=s; aspf=s
TagMeaning
p=rejectPolicy: what to do when DMARC fails. none = monitor only, quarantine = junk folder, reject = block
rua=mailto:...Where to send aggregate reports (daily summary of pass/fail stats)
ruf=mailto:...Where to send forensic reports (per-email failure reports)
pct=100Percentage of failing mail to apply the policy to � 100% means all
adkim=sDKIM alignment mode: s=strict (exact domain match), r=relaxed (subdomain allowed)
aspf=sSPF alignment mode: same options as adkim

// Authentication-Results Header

The receiving mail server writes the results of SPF, DKIM, and DMARC checks into an Authentication-Results: header. This is the quickest way to see the authentication verdict at a glance.

Email Header � authentication pass example
Authentication-Results: mx.victim.org;
    dkim=pass header.i=@example.com header.s=selector1;
    spf=pass (mx.victim.org: domain of sender@example.com designates 203.0.113.10 as permitted sender) smtp.mailfrom=sender@example.com;
    dmarc=pass action=none header.from=example.com
Email Header � spoofing attempt example
Authentication-Results: mx.victim.org;
    dkim=none;
    spf=fail (mx.victim.org: domain of noreply@paypal.com does not designate 185.220.101.42 as permitted sender) smtp.mailfrom=noreply@paypal.com;
    dmarc=fail action=reject header.from=paypal.com

The Authentication-Results: header added by your own mail server is trustworthy. However, a malicious sender can include a fake Authentication-Results: header in the email body. Only trust the one added by the first receiving server you control (the topmost one).

// Identifying Spoofing & Phishing

Once you can read headers, here is what to look for when investigating a suspicious email.

Red flagWhat to check
SPF / DKIM / DMARC failAuthentication-Results � any fail is suspicious, especially for well-known brands
From / Return-Path mismatchFrom: shows paypal.com but Return-Path: shows random-domain.ru
Message-ID domain mismatchFrom: shows paypal.com but Message-ID shows @amazon-support.biz
Received IP reputationExtract the sending IP from Received headers and check on AbuseIPDB, VirusTotal, Shodan
Unusual X-Originating-IPIf present, this is the sender's actual IP � check its location and reputation
Domain lookalikepaypa1.com, pay-pal.com, microsoft-support.net � compare carefully against the real domain
Recently registered domainCheck WHOIS for registration date � phishing domains are often days or weeks old
Excessive hopsLegitimate email rarely passes through more than 4-5 hops � a long Received chain may indicate relaying through compromised servers
Time zone anomaliesDate header in one timezone, Received timestamps in another � may indicate header manipulation

// Extracting IOCs

From a suspicious email, these are the IOCs to extract for further investigation and threat intel lookups.

IP Addresses

Sending IPs from Received headers, X-Originating-IP. Check: AbuseIPDB, VirusTotal, Shodan, Talos Intelligence.

Domains

From domain, Return-Path domain, Message-ID domain, links in the body. Check: VirusTotal, URLscan.io, WHOIS, MXToolbox.

URLs

Links in the email body � do not click directly. Check: URLscan.io, VirusTotal URL, Any.run (sandbox). Use URL defanging: hxxp://evil[.]com

Attachments

Hash the file (MD5, SHA256) and submit to VirusTotal or Any.run. Never open directly � use a sandbox.

Defang your IOCs. When sharing or documenting IOCs, defang URLs and IPs to prevent accidental clicks: replace http with hxxp, wrap dots in brackets (evil[.]com), and replace @ in email addresses with [@]. This is standard practice in SOC reporting.

// Analysis Tools

ToolUse case
Google Admin Toolbox � Message Header AnalyserPaste raw headers for a visual, parsed breakdown of the Received chain and authentication results
MXToolbox Header AnalyserParses headers and highlights delays, flags SPF/DKIM/DMARC issues, shows hop-by-hop timing
MXToolbox SPF / DKIM checkerLook up and validate the SPF / DKIM DNS records for any domain
AbuseIPDBCheck sending IPs against a crowdsourced database of reported malicious addresses
VirusTotalCheck IPs, domains, URLs, and file hashes against 70+ security vendor databases
URLscan.ioSubmit URLs for sandboxed rendering � shows what the page looks like and any redirects/scripts
Cisco Talos IntelligenceIP and domain reputation, email sender reputation, threat intelligence context
PhishToolAutomated email header parsing, attachment analysis, and IOC extraction purpose-built for phishing triage