SMTP Pentest Guide

Authentication Results Injection

This attack involves injecting fake Authentication-Results headers into emails to make them appear to have passed authentication checks when they haven't.

Attack Summary: Injecting fake Authentication-Results headers to make emails appear to have passed authentication checks.

Background: Authentication-Results Headers

The Authentication-Results header is defined in RFC 8601 and is used by email servers to indicate the results of various authentication checks performed on an incoming email. These checks typically include:

  • SPF (Sender Policy Framework): Verifies that the sending server is authorized to send email for the domain in the From header
  • DKIM (DomainKeys Identified Mail): Verifies that the email was cryptographically signed by the domain in the From header
  • DMARC (Domain-based Message Authentication, Reporting, and Conformance): Verifies that the email passes SPF and/or DKIM checks and that the From header domain aligns with the authenticated domain

The Authentication-Results header is added by the receiving email server after it performs these checks. It is intended to be used by downstream systems (such as email clients) to determine whether an email is legitimate.

Attack Methodology

This attack exploits the fact that some email systems may not properly validate or strip Authentication-Results headers from incoming emails. If an attacker can inject a fake Authentication-Results header into an email, they may be able to make it appear that the email has passed authentication checks when it hasn't.

Basic Authentication-Results Injection
Injecting fake Authentication-Results headers

This variant involves injecting a fake Authentication-Results header into an email to make it appear that the email has passed authentication checks.

Basic Injection Example

Injecting a fake Authentication-Results header

# Send an email with a fake Authentication-Results header telnet mail.example.com 25 HELO attacker.com MAIL FROM: attacker@attacker.com RCPT TO: victim@example.com DATA From: ceo@trusted-company.com To: victim@example.com Subject: Urgent Wire Transfer Authentication-Results: mx.example.com; spf=pass (example.com: domain of ceo@trusted-company.com designates 192.0.2.1 as permitted sender) smtp.mailfrom=ceo@trusted-company.com; dkim=pass header.d=trusted-company.com; dmarc=pass action=none header.from=trusted-company.com Please process this wire transfer immediately. . QUIT
Explanation: In this example, the attacker sends an email with a spoofed From header (ceo@trusted-company.com) and includes a fake Authentication-Results header that makes it appear that the email has passed SPF, DKIM, and DMARC checks. If the receiving email server does not strip or validate this header, downstream systems may trust the email as legitimate.

How It Works

  1. Attacker sends an email with a spoofed From header
  2. Attacker includes a fake Authentication-Results header in the email
  3. The fake header indicates that the email has passed SPF, DKIM, and DMARC checks
  4. If the receiving email server does not strip or validate this header, it will be passed to downstream systems
  5. Downstream systems (such as email clients) may trust the email as legitimate based on the fake Authentication-Results header
Multiple Authentication-Results Injection
Injecting multiple Authentication-Results headers

This variant involves injecting multiple Authentication-Results headers into an email to confuse downstream systems.

Multiple Injection Example

Injecting multiple Authentication-Results headers

# Send an email with multiple Authentication-Results headers telnet mail.example.com 25 HELO attacker.com MAIL FROM: attacker@attacker.com RCPT TO: victim@example.com DATA From: ceo@trusted-company.com To: victim@example.com Subject: Urgent Wire Transfer Authentication-Results: mx.example.com; spf=fail (example.com: domain of ceo@trusted-company.com does not designate 192.0.2.2 as permitted sender) smtp.mailfrom=ceo@trusted-company.com; dkim=fail; dmarc=fail Authentication-Results: mx.example.com; spf=pass (example.com: domain of ceo@trusted-company.com designates 192.0.2.1 as permitted sender) smtp.mailfrom=ceo@trusted-company.com; dkim=pass header.d=trusted-company.com; dmarc=pass action=none header.from=trusted-company.com Please process this wire transfer immediately. . QUIT
Explanation: In this example, the attacker sends an email with a spoofed From header (ceo@trusted-company.com) and includes multiple Authentication-Results headers. The first header indicates that the email has failed SPF, DKIM, and DMARC checks, while the second header indicates that the email has passed these checks. Depending on how downstream systems process these headers, they may trust the email as legitimate based on the second header.

Header Processing Inconsistencies

Different email systems may process multiple Authentication-Results headers differently:

  • First header wins: Some systems may only consider the first Authentication-Results header
  • Last header wins: Some systems may only consider the last Authentication-Results header
  • Most secure wins: Some systems may choose the most secure result (e.g., fail over pass)
  • Least secure wins: Some systems may choose the least secure result (e.g., pass over fail)
  • Confusion: Some systems may become confused and default to a specific behavior
Trusted Server Impersonation
Impersonating a trusted email server

This variant involves impersonating a trusted email server in the Authentication-Results header.

Trusted Server Impersonation Example

Impersonating a trusted email server

# Send an email with an Authentication-Results header impersonating a trusted server telnet mail.example.com 25 HELO attacker.com MAIL FROM: attacker@attacker.com RCPT TO: victim@example.com DATA From: ceo@trusted-company.com To: victim@example.com Subject: Urgent Wire Transfer Authentication-Results: mx.google.com; spf=pass (google.com: domain of ceo@trusted-company.com designates 192.0.2.1 as permitted sender) smtp.mailfrom=ceo@trusted-company.com; dkim=pass header.d=trusted-company.com; dmarc=pass action=none header.from=trusted-company.com Please process this wire transfer immediately. . QUIT
Explanation: In this example, the attacker sends an email with a spoofed From header (ceo@trusted-company.com) and includes an Authentication-Results header that impersonates a trusted email server (mx.google.com). If the receiving email system trusts Authentication-Results headers from this server, it may trust the email as legitimate.

Trusted Server Identification

Attackers can identify trusted servers by:

  • Examining existing emails: Looking at Authentication-Results headers in legitimate emails
  • Public information: Many organizations publish information about their email infrastructure
  • DNS records: MX records can reveal the email servers used by a domain
  • Common providers: Impersonating well-known email providers (e.g., Google, Microsoft)
  • Trial and error: Testing different server names to see which ones are trusted

Impact

This attack allows attackers to:

  • Make spoofed emails appear to have passed authentication checks
  • Bypass email filtering systems that rely on Authentication-Results headers
  • Increase the likelihood that recipients will trust and act on malicious emails
  • Conduct more effective phishing and business email compromise attacks

Detection

Organizations can detect these attacks by:

  • Configuring email servers to strip or validate Authentication-Results headers from incoming emails
  • Implementing email security solutions that perform their own authentication checks
  • Monitoring for inconsistent or suspicious Authentication-Results headers
  • Checking for Authentication-Results headers that claim to be from trusted servers but aren't

Mitigation

To protect against these attacks, organizations should:

  • Strip incoming headers: Configure email servers to strip Authentication-Results headers from incoming emails
  • Add trusted headers: Add Authentication-Results headers based on their own authentication checks
  • Validate headers: If not stripping headers, validate that they come from trusted servers
  • Implement authentication: Implement SPF, DKIM, and DMARC for all domains
  • Use email security: Implement email security solutions that perform their own authentication checks
  • Train users: Educate users about the risks of email spoofing and phishing

Testing

Security professionals can test for this vulnerability using the following approach:

  1. Send test emails with fake Authentication-Results headers
  2. Check if the headers are stripped or validated by the receiving email server
  3. Check if downstream systems trust the fake headers
  4. Test different header variations to identify processing inconsistencies
  5. Document the results and recommend appropriate mitigations

References