TCP Spoofing: Reliable Payload Transmission Past the Spoofed TCP Handshake

Yepeng Pan, Christian Rossow

IEEE Symposium on Security and Privacy 2024 · Day 3 · Continental Ballroom 4

Overview

This talk, "TCP Spoofing: Reliable Payload Transmission Past the Spoofed TCP Handshake," presented by Yepeng Pan and Christian Rossow at IEEE S&P, delves into advanced techniques for exploiting TCP spoofing vulnerabilities. While traditional TCP spoofing attacks have focused primarily on establishing a connection by predicting or brute-forcing the server's Initial Sequence Number (ISN), this research addresses the far more challenging problem of reliably transmitting arbitrary payloads after the handshake is complete. The motivation for such an attack is to bypass IP-based authentication and blocklisting mechanisms, which are still widely used in various systems, from email (Sender Policy Framework - SPF) to databases (e.g., PostgreSQL IP-based user verification) and network access controls.

Watch on YouTube

Visual summary for TCP Spoofing: Reliable Payload Transmission Past the Spoofed TCP Handshake by Yepeng Pan, Christian Rossow
Visual summary for TCP Spoofing: Reliable Payload Transmission Past the Spoofed TCP Handshake by Yepeng Pan, Christian Rossow

Key moments

  1. 0:00 Introduction to TCP spoofing and its motivation
  2. 1:35 The attacker's challenge: unknown ISN and connection state
  3. 3:30 Ghost ACK: exploiting permissive window checking for payload injection
  4. 5:00 Ghost ACK confirmed in OS, IETF working on fix
  5. 5:55 Feedback channels: Using Linux Syn Cookies to learn ISN
  6. 7:40 Detecting successful spoofed connections using Syn Cookie ISN
  7. 8:50 Feedback channel effectiveness in local and remote experiments

TCP Spoofing: Reliable Payload Transmission Past the Spoofed TCP Handshake

Speakers: Yepeng Pan; Christian Rossow

Conference: IEEE S&P

YouTube: https://www.youtube.com/watch?v=nRHKrhxTX-0

Overview

This talk, "TCP Spoofing: Reliable Payload Transmission Past the Spoofed TCP Handshake," presented by Yepeng Pan and Christian Rossow at IEEE S&P, delves into advanced techniques for exploiting TCP spoofing vulnerabilities. While traditional TCP spoofing attacks have focused primarily on establishing a connection by predicting or brute-forcing the server's Initial Sequence Number (ISN), this research addresses the far more challenging problem of reliably transmitting arbitrary payloads after the handshake is complete. The motivation for such an attack is to bypass IP-based authentication and blocklisting mechanisms, which are still widely used in various systems, from email (Sender Policy Framework - SPF) to databases (e.g., PostgreSQL IP-based user verification) and network access controls.

The core contribution of this work lies in identifying two novel attack primitives that enable an attacker to effectively use a spoofed TCP connection for data exfiltration or injection. These primitives are the exploitation of a "ghost ACK" vulnerability, which allows an attacker to brute-force the server's send window, and the discovery of various "feedback channels" that reliably expose the server's actual ISN to the attacker. By overcoming the critical hurdle of not knowing the server's precise sequence and acknowledgment numbers post-handshake, this research significantly elevates the threat posed by TCP spoofing, demonstrating how attackers can now not only establish but also utilize these deceptive connections to compromise systems relying on IP-based trust.

Background

▶ Watch: Introduction to TCP spoofing and its motivation (0:00)

TCP spoofing, at its foundation, involves an attacker forging the source IP address of a legitimate victim in TCP packets to interact with a target server. The primary goal is often to impersonate the victim, thereby circumventing security measures that grant access or trust based on IP address. Historically, the most significant challenge in executing a successful TCP spoofing attack has been establishing the connection itself. This initial phase requires the attacker to predict or brute-force the server's Initial Sequence Number (ISN), a randomly generated 32-bit number that initializes the sequence number for a new TCP connection. In the past, predictable ISN generation in some operating systems made this task feasible. However, modern operating systems have significantly improved their ISN generation algorithms, making prediction impractical.

The alternative approach for establishing a spoofed connection involves brute-forcing the ISN. An attacker sends a SYN packet with the victim's spoofed IP address. The server responds with a SYN-ACK packet to the victim, containing its ISN. Since the victim did not initiate this connection, it typically responds with a RST packet. To counter this, the attacker floods the server with a large number of spoofed ACK packets, each attempting to acknowledge a different potential ISN. If one of these ACKs correctly acknowledges the server's ISN, the server will transition the connection to an established state. The victim's RST might still arrive, but if the attacker's correct ACK arrives first, a brief window of opportunity for the spoofed connection exists.

However, even if a spoofed connection is successfully established through brute-forcing, a critical problem remains: the attacker does not know the exact ISN used by the server, nor the server's current send window. Without this information, the attacker cannot craft subsequent packets with the correct sequence (SEQ) and acknowledgment (ACK) numbers required for reliable data transmission. TCP requires precise SEQ and ACK values for data to be accepted by the receiver. This fundamental lack of knowledge has historically limited the utility of spoofed TCP connections primarily to denial-of-service attacks or very short-lived, fire-and-forget payload injections. This talk directly addresses this gap, providing mechanisms for an attacker to gain the necessary information to reliably use the spoofed connection for arbitrary payload transmission.

Key Findings

▶ Watch: Ghost ACK: exploiting permissive window checking for payload injection (3:30)

The research presented in this talk uncovers two primary attack primitives that fundamentally change the landscape of TCP spoofing, allowing for reliable payload transmission over established but spoofed connections. These findings address the long-standing challenge of an attacker not knowing the server's sequence and acknowledgment numbers post-handshake.

The first key finding is the identification and exploitation of the "ghost ACK" vulnerability. This vulnerability stems from permissive ACK validation in newly established TCP connections across several major operating systems. It allows an attacker to effectively "brute-force" the server's send window by sending ACKs for data the server has not yet sent. This effectively tricks the server into opening its send window, enabling the attacker to inject payloads. This behavior was verified across Windows, BSD, and Linux (though Linux has since patched the initial upstream issue). The problem has also been reported to the IETF, which is actively working on an internet draft to improve ACK validation standards.

The second, and arguably more potent, finding is the discovery of various feedback channels that allow an attacker to accurately learn the server's precise ISN and, consequently, its send window. These feedback channels are categorized into two types:

  1. SYN cookie-based feedback: Exploiting subtle differences in ISN generation when the Linux kernel's SYN backlog queue is full (triggering SYN cookies) versus when it's not. By observing the ISN generation pattern, an attacker can infer the state of the SYN backlog and, crucially, deduce when a spoofed connection has been successfully established and which ACK number led to that success. While subject to network noise, this method achieved 50% accuracy in local setups and 70% in remote environments.
  2. Application-specific feedback: This category leverages the behavior of specific applications running on the target server. The talk highlighted SMTP (Simple Mail Transfer Protocol) as a prime example, demonstrating how DNS lookups, direct email delivery, or bounce messages triggered by attacker-controlled payloads can leak the server's ISN. These application-specific channels are particularly powerful as they can reliably acknowledge successful spoofing and reveal the exact ISN. A prevalence study indicated that at least 25% of the top 10,000 domains with email servers were susceptible to at least one of these SMTP-based feedback mechanisms.

In summary, these findings demonstrate that TCP spoofing is no longer limited to connection establishment. With the "ghost ACK" primitive and various feedback channels, attackers can now reliably inject or exfiltrate data, posing a significant threat to systems that rely on IP-based authentication for security.

Technical Deep Dive

▶ Watch: Ghost ACK confirmed in OS, IETF working on fix (5:00)

The core of this research lies in two distinct yet complementary attack primitives: brute-forcing the send window via ghost ACKs and utilizing feedback channels to learn the server's ISN.

Brute-Forcing the Send Window with Ghost ACKs

TCP's reliability mechanism relies on sequence and acknowledgment numbers, coupled with a sliding window. For an established connection, the server maintains pointers: send next (the next byte to be sent) and send unacknowledged (the first byte sent but not yet acknowledged). According to RFCs, an incoming ACK segment is typically considered valid if its acknowledgment number (AR value) falls within the range [send unacknowledged, send next]. ACKs outside this range are usually rejected or treated as duplicates.

However, a critical permissive behavior was identified in newly established TCP connections. When a connection is first established, send unacknowledged and send next are both initialized to ISN + 1. The standard, as implemented in several operating systems, allows for old AR values (i.e., less than ISN + 1) to be accepted, provided they are not "too old" and fall within the maximum receive window. Crucially, because no data has been sent yet, the server has never used these "old AR values" for actual data. This loophole creates the "ghost ACK" vulnerability.

An attacker can exploit this by sending ACK packets with payloads, where the ACK number is chosen from a range before the server's ISN + 1. By splitting the entire potential send window (which can be up to 1 GB with window scaling) into equal window-sized pieces, the attacker can try one ACK number per piece. One of these "ghost ACKs" will eventually be accepted, effectively acknowledging data the server never sent and thus advancing its send unacknowledged pointer. This action opens the server's send window, allowing the attacker's payload to be injected into the connection. The talk verified this behavior in Windows, BSD, and Linux. While Linux has since patched this specific initial upstream issue, the problem was significant enough to be reported to the IETF, which is now working on an internet draft to standardize stricter ACK validation.

Feedback Channels for ISN Discovery

Even with ghost ACKs, the attacker still ideally needs to know the server's exact ISN to precisely control the connection. Feedback channels provide this crucial information.

1. SYN Cookie-Based Feedback (Linux Specific)

This technique exploits the behavior of Linux's SYN backlog queue and SYN cookies, a SYN flood defense mechanism.

  • Normal ISN Generation (Queue Not Full): When the SYN backlog queue for a listening socket is not full, the kernel stores the received SYN packet in the queue and sends a normal SYN-ACK. The ISN for this SYN-ACK is generated based on a hash computation over the 5-tuple (source IP, source port, destination IP, destination port, protocol) plus a clock counter that updates frequently (e.g., every 64 nanoseconds). This rapid update means that repeated SYN probes from the same 5-tuple will yield different, non-inferable ISNs.
  • SYN Cookie ISN Generation (Queue Full): If the SYN backlog queue is full (e.g., during a SYN flood), the server activates SYN cookies. It no longer stores the SYN packet in the queue but instead sends a SYN-ACK with a SYN cookie as its ISN. Crucially, in this mode, the clock counter used for ISN generation updates much less frequently (e.g., every 1 minute). This means that repeated SYN probes from the same 5-tuple within that 1-minute window will yield the same ISN.

The attack flow leverages this difference:

  1. The attacker first fills the server's SYN backlog queue, including sending one spoofed SYN from the victim's IP.
  2. The attacker then repeatedly sends SYN probes from the same address tuple to the server. If the queue is full (SYN cookie active), the attacker observes non-inferable, but stable ISNs for a 1-minute period.
  3. The attacker then sends an ACK packet, attempting to establish the spoofed connection.
  4. If the spoofed connection is successfully established, it is removed from the SYN backlog queue, freeing up space.
  5. The attacker immediately sends new SYN probes from the same address tuple. Now, because the queue is no longer full, the server reverts to normal ISN generation (clock counter updates every 64ns). The attacker observes frequently changing ISNs.
  6. The change in ISN generation behavior (from stable to rapidly changing) signals to the attacker that the spoofed connection was successfully established, and the ACK that caused this change is the correct one, implicitly revealing the server's ISN.

This method's accuracy was tested at 50% in local setups and 70% in remote setups. Inaccuracies primarily stem from network noise (packet reordering, packet loss), legitimate user connection requests interfering with the queue state, and the occasional 1-minute time shift of SYN cookie's internal clock.

2. Application-Specific Feedback (e.g., SMTP)

This category of feedback channels is highly reliable and always acknowledges successful spoofing, providing the exact ISN. It requires the attacker to target a specific application running on the server and relies on that application's behavior to leak information. The talk focused on SMTP:

  • DNS Lookup Feedback:
  • SMTP servers often perform Sender Policy Framework (SPF) checks, which involve resolving DNS records for the domain specified in the MAIL FROM: command.
  • The attacker embeds the server's expected ISN into a specially crafted domain name within the MAIL FROM: command (e.g., MAIL FROM:<isnum-12345678.attacker.com>).
  • If the spoofed connection is successful and the payload containing this command is accepted, the target SMTP server will perform a DNS lookup for isnum-12345678.attacker.com.
  • The attacker, controlling attacker.com's DNS server, logs this lookup, thereby extracting the exact ISN.
  • Email Delivery Feedback:
  • The attacker can register an email address on a public email server (e.g., [email protected]) or one they control.
  • The payload in the spoofed ACK is crafted to send an email to this attacker-controlled mailbox, with the ISN embedded in the email's subject or body.
  • If spoofing is successful, the server delivers the email. The attacker receives the email and extracts the ISN.
  • Bounce Message Feedback:
  • The attacker sets up their own mail server.
  • The payload crafts an email to a non-existent address on the target server, or an address configured for auto-reply. The MAIL FROM: address is an attacker-controlled address (e.g., [email protected]).
  • If spoofing is successful, the target server attempts delivery, fails, and sends a bounce message back to [email protected].
  • The attacker's mail server receives the bounce, and the ISN can be extracted from the bounce message's recipient address or body.

These SMTP-based feedback channels were found to be highly prevalent, with at least 25% of the top 10,000 email servers being susceptible to at least one of these methods. The reliability and precision of these application-specific techniques make them a particularly potent tool for attackers.

Demo / Proof of Concept

▶ Watch: Detecting successful spoofed connections using Syn Cookie ISN (7:40)

While the talk did not feature a live, interactive demonstration, the speakers presented compelling experimental results and prevalence statistics that serve as a robust proof of concept for their identified vulnerabilities and attack primitives.

For the ghost ACK primitive, the researchers verified the permissive ACK validation behavior across multiple operating systems, specifically mentioning Windows, BSD, and Linux. This verification involved crafting packets to demonstrate that these systems would accept ACKs for data not yet sent, effectively opening the send window on a newly established spoofed connection. The fact that Linux has since patched this initial upstream issue and the IETF is working on a new internet draft further underscores the validity and impact of this finding.

Regarding the SYN cookie-based feedback channel, experiments were conducted in both local and remote network environments. The results demonstrated the feasibility of inferring the success of a spoofing attempt and the server's ISN by observing the distinct ISN generation patterns (frequent vs. infrequent clock counter updates) under normal and SYN cookie conditions. The reported accuracy of 50% in local setups and 70% in remote setups quantifies the practical effectiveness of this method, despite the inherent noise sources like packet reordering, loss, and legitimate user traffic.

For the application-specific feedback channels, particularly those leveraging SMTP, the researchers conducted a prevalence study against the top 10,000 domains with email servers. This large-scale experiment revealed that a significant proportion – at least 25% – of these email servers were susceptible to at least one of the demonstrated feedback mechanisms (DNS lookups, direct email delivery, or bounce messages). This empirical data strongly validates the practical applicability and widespread impact of these techniques, showing that they are not merely theoretical exploits but rather real-world vulnerabilities affecting a substantial portion of internet infrastructure. The ability to embed the ISN into DNS queries or email content and retrieve it through attacker-controlled services serves as a clear proof of concept for reliable payload transmission and ISN discovery.

Defensive Implications

▶ Watch: Feedback channel effectiveness in local and remote experiments (8:50)

The findings presented in this talk have significant implications for network defenders, highlighting critical weaknesses in existing security paradigms, particularly those relying on IP-based authentication.

  1. Stricter ACK Validation for TCP Stacks:
  • The ghost ACK vulnerability points to a need for more robust and less permissive ACK validation in TCP/IP stack implementations. Operating systems should strictly reject ACKs for data that has not yet been sent, especially for newly established connections where the send window is effectively empty.
  • Defenders should ensure their systems are running the latest kernel versions, particularly for Linux, which has already patched the initial upstream issue related to ghost ACKs. Monitoring and applying updates for Windows and BSD systems that might still be vulnerable is crucial.
  • The ongoing work by the IETF on an internet draft to improve ACK validation standards should be closely followed and implemented once finalized.
  1. Rethink IP-Based Authentication:
  • The most fundamental takeaway is that IP-based authentication is fundamentally flawed and unreliable when TCP spoofing with payload transmission is possible. Any system that grants access, trust, or sensitive information based solely on the source IP address of a TCP connection is at risk.
  • This includes firewalls with IP allow-lists, database systems authenticating users by IP, and email systems relying on SPF for sender verification.
  • Defenders should prioritize migrating away from IP-based authentication to stronger, multi-factor authentication mechanisms that verify the identity of the user or client, not just their network address.
  1. Secure Application Logic (Especially for SMTP):
  • Applications, particularly those that perform external actions based on incoming data from newly established connections (like SMTP servers), need to be hardened.
  • SMTP servers should implement stricter input validation on commands like MAIL FROM:. Instead of blindly performing DNS lookups for arbitrary domains provided by an unauthenticated sender, they should validate the domain against known legitimate patterns or defer such lookups until a higher level of authentication or trust is established.
  • Servers should avoid delivering emails or generating bounce messages to arbitrary addresses specified in MAIL FROM: until the sender's authenticity is confirmed. This means not performing actions that could leak information (like ISNs) until after secure authentication.
  • Consider implementing rate limiting and behavioral analysis for DNS lookups triggered by SMTP sessions to detect anomalous patterns indicative of ISN probing.
  1. Enhanced SYN Flood Defenses:
  • While SYN cookies are a vital defense against SYN floods, the fact that their ISN generation pattern can be exploited for feedback (in Linux) suggests a need for re-evaluation.
  • Kernel developers might need to investigate ways to make ISN generation less predictable or consistent, even under SYN cookie conditions, to prevent its use as an oracle for connection success.
  • Defenders should also deploy layered SYN flood defenses, including hardware-based solutions and network-level filtering, to reduce the reliance solely on OS-level SYN cookie mechanisms.
  1. Network Monitoring and Anomaly Detection:
  • Implement robust network monitoring to detect unusual TCP traffic patterns, such as a flood of ACK packets targeting a single server, especially those with small or identical payloads.
  • Look for anomalous DNS queries originating from internal mail servers that correspond to non-existent or unusual domains, which could indicate ISN probing via application-specific feedback.
  • Monitor for a sudden increase in bounce messages or unexpected emails to attacker-controlled domains, which might signal successful spoofing attempts.

By addressing these defensive implications, organizations can significantly reduce their exposure to these advanced TCP spoofing attacks and bolster the security of their critical infrastructure.

Key Takeaways

  • TCP Spoofing is Evolving: Attackers can now reliably transmit payloads over spoofed TCP connections, moving beyond just establishing the handshake.
  • Ghost ACK Vulnerability: A flaw in TCP stack implementations (Windows, BSD, older Linux) allows attackers to "brute-force" the server's send window by sending ACKs for data not yet transmitted, enabling payload injection.
  • Feedback Channels for ISN Discovery: Novel techniques, including SYN cookie behavior in Linux and application-specific responses (e.g., SMTP), allow attackers to precisely learn the server's Initial Sequence Number (ISN) and current send window.
  • Application-Specific Attacks are Potent: SMTP-based feedback channels (DNS lookups, email delivery, bounce messages) are particularly effective, reliable, and prevalent, affecting at least 25% of the top 10K email servers.
  • IP-Based Authentication is Compromised: The ability to reliably inject payloads into spoofed connections fundamentally undermines the security of systems that rely on source IP address for authentication, authorization, or trust.
  • Urgent Need for Defensive Action: Defenders must update OS kernels, implement stricter ACK validation, critically re-evaluate and replace IP-based authentication with stronger methods, and harden application logic to prevent information leakage through feedback channels.

About the Speaker(s)

Yepeng Pan and Christian Rossow are the researchers who presented this work on advanced TCP spoofing techniques at the IEEE S&P conference. Based on the talk, their research focuses on identifying and exploiting vulnerabilities in network protocols and operating system implementations to enhance our understanding of system security.

Reviews

Dr. Zero (Offensive Security Researcher) — MUST SEE

This research obliterates the illusion that TCP spoofing is limited to connection establishment. The "ghost ACK" vulnerability and the ingenious feedback channels, particularly via SMTP, enable reliable payload transmission, fundamentally compromising IP-based authentication. This is critical, actionable intelligence for any defender.

Heather Calloway (CISO) — MUST SEE

This research fundamentally undermines the security of IP-based authentication, demonstrating how attackers can reliably transmit payloads over spoofed TCP connections. It compels a critical re-evaluation of trust models, demanding immediate architectural and policy shifts for any organization relying on source IP for access control.

→ Top-rated talks at IEEE Symposium on Security and Privacy 2024

All talks from IEEE Symposium on Security and Privacy 2024