Back to blog
Threat Intel
Phishing Forensics

The Defender's Blind Spot: Bypassing SEGs via Backup MX Records

Leaving a low-priority cloud MX record in DNS offers no real failover, but rather hands threat actors a completely undefended route straight into your users' inboxes.

MailSleuth Research
Email Security Team
September 16, 20267 min read
A heavily armored vault door next to a small, unguarded open side door in a dark setting.

You spend six figures on a top-tier secure email gateway, confident that every inbound message faces rigorous inspection before touching an inbox. Your SOC dashboards light up with blocked credential harvesting links, detonated malware payloads, and quarantined business email compromise attempts. From the outside, your perimeter looks heavily fortified, operating exactly as designed by passing traffic exclusively through an advanced filtering engine.

But the reality of email routing is dictated by public infrastructure, and many organizations leave a silent, gaping hole sitting in plain text in their domain records. During migrations from legacy on-premises Exchange servers or standard cloud deployments, administrators frequently retain their original Microsoft 365 or Google Workspace MX records. They demote these records to a lower priority, assuming they act as a harmless failover mechanism should the primary gateway suffer an unexpected outage.

This legacy configuration hands attackers a direct path past your defenses. By intentionally targeting the secondary route, threat actors exploit a classic seg bypass mx record vulnerability, circumventing your expensive inspection layers completely. Threat actors do not care about your intended routing logic. They care about what network sockets are open and accepting connections, and if your cloud tenant is willing to speak to them directly, your gateway is effectively a suggestion rather than a mandate.

The Illusion of SMTP Fallback

The standard enterprise email architecture relies entirely on establishing a central choke point. You configure your public DNS zone to point your primary MX record to a gateway like Proofpoint, Mimecast, or Trellix. This platform sits at the very edge of your network envelope, absorbing all inbound SMTP connections. It performs sender reputation checks, executes URL rewriting, evaluates SPF and DKIM alignment, and then forwards only the clean, verified mail downstream to your Microsoft 365 or Google Workspace environment.

The Mechanics of Preference

The vulnerability takes root when organizations misunderstand how the SMTP protocol handles delivery failures. RFC 5321 dictates that a sending Mail Transfer Agent must attempt delivery to the highest priority MX record first. If that server issues a temporary failure code or simply times out, the sender is supposed to fall back to the next record in the sequence. IT teams exploit this specification to create redundancy, leaving a priority twenty record pointing to contoso-com.mail.protection.outlook.com while placing their gateway at priority ten.

The critical flaw in this logic is treating MX preference as a security boundary. DNS is merely an address book providing directions to the public internet. Priority flags are polite suggestions for legitimate senders operating compliant mail transfer agents. They are not physical firewall rules, and they offer zero protection against a client that decides to ignore the sequence entirely.

The Red Team Reconnaissance Playbook

Offensive operators view email infrastructure not as a sequential process, but as a map of available attack surfaces. When an advanced persistent threat group or a specialized initial access broker prepares a spear-phishing campaign, their first step is passive reconnaissance. They use standard command-line utilities to query the target domain's public records, mapping out exactly where the organization hosts its mail and what security vendors sit in front of it.

If an attacker sees a priority ten record pointing to a known enterprise gateway, they understand that delivering a malicious payload through that route requires evading complex heuristics, behavioral analysis, and sandboxing. But if they also spot a lower priority record pointing directly to Microsoft 365 infrastructure, the operation becomes significantly easier. They immediately abandon the primary route.

Attackers do not politely attempt your priority ten gateway, fail, and then try priority twenty. They script their offensive infrastructure to open a socket directly to the lowest-priority record, completely circumventing your primary security stack.

Exploiting the Direct Route

Using custom Python scripts or modified mail utilities, the attacker forces their infrastructure to connect directly to the priority twenty destination. This direct connection forces the cloud tenant to act as the primary edge receiver. Because the email physically bypassed the gateway, none of the organization's custom routing rules, attachment blocking policies, or executive impersonation protections apply. Microsoft 365 evaluates the message using only its baseline default rules, which are often severely downgraded because administrators assume the gateway is handling the heavy lifting.

Hunting the Bypass in Email Headers

When a high-fidelity business email compromise attack lands in an executive's inbox, incident responders must immediately trace the physical path the message took across the internet. This requires a forensic teardown of the SMTP headers, reading the Received chain from the bottom up to map every network hop.

Identifying the Missing Gateway Stamp

In a hardened, properly configured architecture, the sequence of hops is predictable. The bottom-most external Received header will document the sender's infrastructure connecting to your gateway's public IP address. The next hop up will document your gateway handing the message off to your Microsoft 365 tenant. The IP addresses involved will correspond strictly to published, trusted vendor ranges.

When an attacker routes around your defenses, that middle hop vanishes. The bottom-most Received header will show the malicious sender's IP address connecting directly to a Microsoft endpoint. There is no handoff from a trusted security appliance. The cloud tenant itself accepts the connection from a totally untrusted source on the public internet.

Authentication-Results: spf=pass (sender IP is 198.51.100.42) smtp.mailfrom=attacker.xyz; dkim=pass (signature was verified) header.d=attacker.xyz; dmarc=pass action=none header.from=attacker.xyz;

Beyond the routing sequence, the authentication evaluation tells a critical story. In a bypass scenario, the Authentication-Results header is generated by Microsoft 365 directly evaluating the attacker's infrastructure, rather than your gateway passing down its own verdicts. You will also typically observe the X-MS-Exchange-Organization-AuthAs header marked as Anonymous, confirming an unauthenticated session was established straight into the tenant.

Hardening the Cloud Perimeter

Closing this backdoor requires a fundamental shift in how you secure cloud environments. You cannot rely on DNS priority to dictate network flow. To guarantee that every inbound message undergoes gateway inspection, you must lock down the destination tenant so that it absolutely rejects SMTP connections originating from anywhere other than your authorized security infrastructure.

Enforcing IP-Based Connectors

The most immediate remediation is configuring a strict inbound partner connector within the Exchange Admin Center. This connector must be set to restrict mail flow for your accepted domains, forcing the tenant to evaluate the connecting IP address for every inbound transaction. You explicitly define the published egress IP ranges of your secure email gateway within this connector policy. If a threat actor attempts a direct connection, Exchange Online will check their source IP, realize it does not match the approved gateway ranges, and drop the connection before the payload is ever transmitted.

The Certificate Validation Approach

While IP whitelisting is common, maintaining those lists as vendors expand their infrastructure introduces operational overhead. A far more resilient architectural approach is certificate-based enforcement. Instead of matching IP addresses, you configure the inbound connector to require a specific TLS certificate subject name from the connecting party. The gateway presents a cryptographic certificate matching this name during the initial SMTP handshake. This mathematically proves the connecting server is your authorized infrastructure, entirely neutralizing any external entity attempting to force a direct delivery.

The takeaway

Treating cloud infrastructure as an internal network is a fatal architectural error. Publicly routable endpoints are constantly mapped by automated scanners and targeted by offensive operators who read DNS records specifically to identify misconfigurations. A secondary MX record is not an insurance policy; it is an unprotected door left wide open for anyone willing to turn the handle.

Network perimeter logic must be explicitly enforced at the destination, not implied by DNS suggestions. By hardening your inbound connectors, you ensure your security investments actually protect your environment rather than acting as optional filters. When triaging suspicious deliveries to verify your enforcement is working, running the headers through a tool like MailSleuth.AI can immediately highlight missing gateway hops and expose rogue direct connections.

#email-forensics#seg-bypass#mx-records#microsoft-365#threat-hunting#dns-security
MailSleuth Research
Email Security Team

We dissect phishing campaigns and email infrastructure so you don't have to.