XFLTReaT: a new dimension in tunnelling

Balazs Bucsay (Senior Security Consultant · NCC Group)

BruCON 0x09 · Day 2

Overview

In the realm of cybersecurity, tunneling remains a fundamental technique for bypassing network restrictions, maintaining anonymity, and establishing secure communication channels. Balazs Bucsay, a Senior Security Consultant at NCC Group, presented "XFLTReaT: a new dimension in tunnelling" at BruCON, introducing a novel, open-source framework designed to overcome the pervasive limitations of existing tunneling solutions. This talk delves into the architecture and capabilities of XFLTReaT, a modular, Python-based tool that consolidates various tunneling protocols into a single, extensible platform.

Watch on YouTube

Visual summary for XFLTReaT: a new dimension in tunnelling by Balazs Bucsay
Visual summary for XFLTReaT: a new dimension in tunnelling by Balazs Bucsay

Key moments

  1. 0:00 Introduction and speaker's background
  2. 10:48 Problems with existing tunneling tools
  3. 12:08 Introducing XFLTReaT and tunneling basics
  4. 17:00 XFLTReaT's 'check' functionality for network assessment
  5. 27:50 Live demo of XFLTReaT (ICMP and DNS tunnels)
  6. 36:15 Technical details of ICMP and DNS tunneling
  7. 44:00 Offensive and defensive use cases for XFLTReaT
  8. 47:00 Defensive recommendations for network security

XFLTReaT: a new dimension in tunnelling

Speakers: Balazs Bucsay, Senior Security Consultant, NCC Group

Conference: BruCON

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

Overview

In the realm of cybersecurity, tunneling remains a fundamental technique for bypassing network restrictions, maintaining anonymity, and establishing secure communication channels. Balazs Bucsay, a Senior Security Consultant at NCC Group, presented "XFLTReaT: a new dimension in tunnelling" at BruCON, introducing a novel, open-source framework designed to overcome the pervasive limitations of existing tunneling solutions. This talk delves into the architecture and capabilities of XFLTReaT, a modular, Python-based tool that consolidates various tunneling protocols into a single, extensible platform.

Bucsay's presentation highlights the practical challenges faced by both offensive security practitioners (red teams) and defensive teams (blue teams) when confronted with diverse network environments and restrictive firewall policies. Traditional tunneling tools often suffer from a lack of unified support for multiple protocols, difficult modification due to disparate programming languages, and a general state of being unsupported or end-of-life. XFLTReaT addresses these critical shortcomings by offering a streamlined, object-oriented framework that simplifies the creation, deployment, and management of tunnels over protocols like TCP, UDP, ICMP, DNS, HTTP CONNECT, SCTP, and WebSockets.

The significance of XFLTReaT lies in its potential to revolutionize how security professionals approach network bypass and reconnaissance. For red teams, it provides an agile toolset for evading detection and exfiltrating data, even in highly controlled environments. For blue teams, it offers a powerful mechanism to proactively identify and mitigate network weaknesses by simulating advanced bypass techniques. By presenting a versatile and easily customizable framework, Bucsay empowers the community to adapt and extend tunneling capabilities, fostering a more resilient and informed security posture against evolving threats.

Background

▶ Watch: Introduction and speaker's background (0:00)

The concept of Virtual Private Networks (VPNs) and tunnels is well-established in network security, allowing users to create a secure, encrypted connection over a less secure network, effectively extending a private network across a public one. Common examples like OpenVPN and Cisco AnyConnect are widely used for remote access, enabling employees to securely connect to corporate resources from outside the office. Beyond corporate access, VPNs are crucial for users seeking to hide their IP addresses, ensure anonymity for whistleblowers or journalists, or bypass geo-restrictions and ISP throttling. Bucsay himself recounted using VPNs to circumvent his ISP's filtering of SMTP ports, highlighting the personal utility of such solutions.

However, the practical application of tunneling, particularly in adversarial or testing scenarios, often encounters significant hurdles. Network administrators frequently implement stringent firewall rules, captive portals, and proxy servers that restrict outbound traffic to a limited set of protocols or ports, such as HTTP (port 80) and HTTPS (port 443). Bucsay shared personal anecdotes from ferry rides and airplane flights where expensive or non-existent internet access prompted him to investigate available unfiltered protocols, often finding ICMP or DNS open. These experiences underscored a recurring problem: while various tools exist for tunneling over specific protocols (e.g., pingtunnel or ICMPTX for ICMP, iodine for DNS), their fragmented nature creates a complex and inefficient landscape.

The speaker identified several critical limitations with the existing ecosystem of tunneling tools:

  • Protocol-specific tools: To tunnel over DNS, ICMP, or TCP, users typically need to install and manage three distinct tools, each with its own configuration and operational nuances.
  • Difficulty in modification: These tools are often written in different programming languages, making it challenging for users to modify or extend their functionality, even to fix bugs or adapt to specific network conditions.
  • End-of-life/unsupported status: Many proof-of-concept tunneling tools eventually become unsupported, leaving users vulnerable to unpatched bugs or incompatible with modern systems.
  • Lack of a unified framework: There was no single, cohesive platform that could abstract away the complexities of interface setup, routing, multi-client handling, and module management, forcing developers to reinvent the wheel for each new tunneling protocol.

This fragmented and often unsupported landscape motivated Bucsay to develop XFLTReaT, a framework designed to consolidate and simplify the entire tunneling process, providing a more robust and adaptable solution for diverse network challenges.

Key Findings

▶ Watch: Introducing XFLTReaT and tunneling basics (12:08)

The core contribution of Balazs Bucsay's work is the XFLTReaT framework, which introduces a new dimension to tunneling by unifying and modularizing the process. The key findings and contributions can be summarized as follows:

  1. Unified, Modular, Object-Oriented Framework: XFLTReaT is presented as a Python-based, open-source, object-oriented framework, not merely a tool. This design allows for the seamless integration of various tunneling protocols as interchangeable modules. This approach significantly reduces the development overhead for new protocols and simplifies deployment, as a single framework can manage multiple tunneling types.
  1. "Russian Doll" Encapsulation: Bucsay vividly illustrates the concept of tunneling using the analogy of a "Russian Doll." This signifies that data packets (the innermost doll) can be encapsulated within another protocol's packet (a larger doll), which can then be further encapsulated within yet another protocol (an even larger doll). This layered approach is fundamental to how XFLTReaT operates, allowing it to wrap arbitrary network traffic within the chosen carrier protocol (e.g., TCP, UDP, ICMP, DNS) to traverse restrictive networks.
  1. Single Interface, Multi-Protocol Support: A significant innovation of XFLTReaT is its ability to manage multiple tunneling protocols through a single network interface and often with a single IPtables or firewall rule. This contrasts sharply with traditional methods that require separate interfaces and complex routing configurations for each tunneling tool, greatly simplifying setup and management on both the client and server sides.
  1. Automated Network Capability Discovery (--check functionality): The framework includes a crucial "check" functionality. This feature allows users to quickly and automatically determine which protocols are open and viable for tunneling on a given network. By sending specific "challenge" packets for each configured protocol and verifying the responses, XFLTReaT can map out network limitations without requiring external tools like Nmap or Scapy.
  1. Separation of Data and Control Channels: XFLTReaT logically separates communication into a data channel and a control channel. The data channel is dedicated to the actual transfer of encapsulated network traffic, while the control channel handles meta-information such as authentication, key exchange (planned), and the results of the check functionality. This separation enhances the framework's robustness and flexibility.
  1. Ease of Module Development and Reusability: The object-oriented design and modular structure make it exceptionally easy to develop new tunneling modules or modify existing ones. Developers only need to focus on the specific encapsulation and decapsulation logic for a new protocol, as the framework handles all the underlying complexities like interface management, routing, and multi-client support. This reusability is demonstrated by how the HTTP CONNECT module can largely reuse the logic developed for the TCP module.

These findings collectively position XFLTReaT as a highly adaptable and efficient solution, addressing long-standing issues in the tunneling landscape and offering a powerful tool for both offensive and defensive security operations.

Technical Deep Dive

▶ Watch: Live demo of XFLTReaT (ICMP and DNS tunnels) (27:50)

XFLTReaT is architected as a robust, Python-based, object-oriented, modular, and multi-client framework. Its design principles prioritize ease of development, flexibility, and comprehensive protocol support, aiming to abstract away the common complexities associated with tunneling.

At its core, XFLTReaT operates on the principle of encapsulation and decapsulation. When a client wants to send data through a tunnel, the framework captures the original network packet (e.g., a TCP SYN request). It then encapsulates this original packet within the payload of a packet belonging to the chosen carrier protocol (e.g., an ICMP echo request). This new, encapsulated packet is sent over the network. On the server side, the XFLTReaT server receives the carrier packet, decapsulates the original packet, and forwards it to its intended destination. The process is reversed for return traffic.

Framework Architecture

  1. Modular Design: The framework is built around a module tree, inheriting properties and methods from parent classes. This includes a Generic module, which provides universal functionalities, and then branches into Stateful and Stateless modules to accommodate the fundamental differences in protocol behavior.
  • Stateful Protocols: These maintain connection state, like TCP, HTTP CONNECT, SCTP, and WebSockets. For stateful tunnels, XFLTReaT typically dedicates a separate socket and thread for each client, simplifying connection management. The HTTP CONNECT module, for instance, leverages the existing TCP tunneling logic, only needing to add the specific HTTP CONNECT method to initiate a bi-directional TCP stream over a proxy.
  • Stateless Protocols: These do not maintain connection state, such as UDP, ICMP, and DNS. For stateless protocols, the server typically uses a single socket to listen for all client traffic. It then relies on internal mechanisms, like the Packet Selector module, to correctly associate incoming packets with the appropriate client and tunnel session.
  1. Unified Interface and Routing: A key feature is the creation of a virtual tunnel interface on both the client and server. This interface is assigned a private IP address. All traffic intended for the tunnel is routed through this interface. The framework then handles the IP address re-addressing (changing public IPs to private VPN IPs and vice-versa) and interacts with the kernel to ensure packets are correctly sent to their ultimate destinations. This unified approach means that regardless of the underlying tunneling protocol, the network's routing table only needs to point to this single virtual interface.
  1. Packet Selector Module: On the server side, after a packet is decapsulated from the carrier protocol, it needs to be re-encapsulated for the return journey to the client. The Packet Selector module is crucial here. It intelligently matches the internal IP address of the decapsulated packet to the correct tunneling module (e.g., ICMP, DNS) that initiated the client's connection. This ensures that the response is encapsulated back into the same protocol used by the client.
  1. Data and Control Channels:
  • Data Channel (WSV): This channel is responsible for the bulk transfer of encapsulated data. It's optimized for high throughput.
  • Control Channel: This is used for meta-communication, including authentication (currently supporting SHA-512 based authentication), key exchange (planned for future encryption features), and the "check" messages used for network reconnaissance.

Protocol-Specific Implementations and Challenges

  • TCP Module: Relatively straightforward due to its stateful nature, allowing dedicated sockets and threads per client.
  • UDP Module: Stateless, requiring a single server socket and careful handling to select and route messages to the correct client.
  • ICMP Module: Also stateless, similar to UDP, but with additional complexities. ICMP packets (especially echo requests/replies, Type 8 and Type 0) contain specific fields like identifier and sequence number. Firewalls and NAT solutions often track these to ensure a one-to-one request-response mapping. This means that if a client is downloading large amounts of data (high downstream), XFLTReaT needs to generate sufficient upstream ICMP requests to keep the "connection" alive and prevent responses from being dropped.
  • DNS Module: This is particularly challenging. While the basic DNS protocol is simple, using it for full tunneling is complex due to various implementations and data transmission methods.
  • DNS as a Server: XFLTReaT can act as a DNS server. Users can provide a zone file containing records for their domain. If a DNS query for a domain name is found in the zone file, XFLTReaT answers it normally. If not, it assumes the query is part of a tunnel and processes it accordingly.
  • A Records vs. CNAME Records for Tunneling: Bucsay explicitly states that using A records (which return an IPv4 address, 4 bytes) for full tunneling is impractical. Even with AAAA records (IPv6, 16 bytes), the payload is too small. A single basic TCP ACK packet is typically 66 bytes, meaning 17 A record requests/responses would be needed for just one ACK, leading to excessive lag. CNAME records, however, can carry significantly more data (150-200 bytes), making them a more viable option for full tunnels.
  • Auto-Tune Feature: The DNS module includes an "auto-tune" capability. This feature dynamically probes the DNS server's capabilities to determine the optimal encoding (e.g., Base128) and maximum length for both upstream and downstream data streams, adapting to the specific network environment. This helps maximize throughput and reliability for DNS tunnels.

Future Development and Current Limitations

While XFLTReaT offers a powerful framework, Bucsay openly acknowledged areas for future development:

  • Encryption: This is a major missing feature. Currently, data within the tunnel is not encrypted, a critical component for secure communication. Key exchange and encryption modules are planned.
  • Operating System Support: Currently, XFLTReaT is primarily Linux-only, with plans to extend support to other operating systems.
  • New Modules: Continuous development of new tunneling modules and refinement of existing ones is ongoing.

By providing a flexible and extensible architecture, XFLTReaT aims to become a community-driven tool, allowing security professionals to adapt and evolve its capabilities to meet new challenges.

Demo / Proof of Concept

▶ Watch: Technical details of ICMP and DNS tunneling (36:15)

Balazs Bucsay conducted a live demonstration of XFLTReaT, showcasing its core functionalities on a setup involving an Amazon EC2 server and a client machine.

The server-side setup involved starting XFLTReaT in server mode, explicitly configuring it to listen on various ports and protocols. The output clearly showed multiple modules running concurrently, including DNS (port 53), HTTP CONNECT, ICMP, SCTP, SOCKS proxy, TCP, UDP, and WebSocket. Some modules, like HTTP CONNECT, were noted as not working because their ports were already in use, demonstrating the framework's ability to attempt multiple protocols simultaneously.

On the client side, the configuration was highlighted, requiring only a few essential parameters:

  • remote_server_ip: The IP address of the Amazon server.
  • interface_name: The name of the virtual network interface created by XFLTReaT (e.g., tun0).
  • server_ip, netmask: IP details for the virtual interface.
  • mtu: Maximum Transmission Unit, with a default value that typically doesn't need modification.
  • authentication: Currently supports salted sha-512 for client-server authentication.
  • Module-specific settings: Enabling/disabling specific tunnel modules (e.g., tcp_generic_enabled = true), and for DNS, specifying hostname and zone_file for its operation as a DNS server.

The --check Functionality

The first part of the demo focused on the --check functionality. Bucsay executed the client with the --check flag. The output displayed a list of configured protocols, each marked with either green or red indicators.

  • Green: Indicated that the protocol was successfully reachable and a challenge-response handshake succeeded, meaning a tunnel could likely be established.
  • Red: Indicated a problem, such as a filtered port or no service listening on the specified IP/port. For example, the SOCKS proxy module showed red because there was no proxy listening on the configured IP. This feature effectively provided an on-the-fly reconnaissance of the network's tunneling capabilities.

ICMP Tunnel Demonstration

Next, Bucsay demonstrated an ICMP tunnel. After ensuring the ICMP module was enabled and a quick --check confirmed its viability, he started the client. Wireshark was launched on the client machine to visualize the network traffic. Initially, Wireshark showed typical ARP traffic. Once the ICMP tunnel was active, he opened NCC Group's webpage in a browser. Wireshark then displayed a flood of ICMP packets, with the original HTTP/TCP traffic encapsulated within them. The webpage loaded successfully, proving the tunnel's functionality. The observed speed for the ICMP tunnel was approximately 266 kilobytes per second (KB/s), demonstrating that ICMP, while often perceived as slow, can be quite effective depending on network conditions.

DNS Tunnel Demonstration

The final part of the demo focused on a DNS tunnel. Bucsay acknowledged that the DNS module was still a "proof-of-concept" and not "production grade." After configuring the client for DNS tunneling, he restarted it. The client output immediately showed the DNS auto-tune process in action. It mapped out the DNS server's capabilities, determining:

  • Whether a raw UDP connection was possible (if so, UDP tunneling would be more efficient).
  • The best encoding for upstream data (identified as Base128).
  • The maximum length for upstream data (determined to be 254 bytes).
  • The best encoding for downstream data (identified as plain text).
  • The maximum length for downstream data (determined to be 229 bytes).

Once the tunnel was established, he opened the BruCON conference webpage. Wireshark, running concurrently, showed exclusively DNS traffic, demonstrating the successful encapsulation of web traffic within DNS queries and responses. The observed download speed for the DNS tunnel ranged from 12-15 KB/s, occasionally peaking at 50-70 KB/s, which Bucsay noted was typical for his testing environment. He also cautioned against using this with an ISP's public DNS server due to the high load it generates.

The demo effectively illustrated XFLTReaT's ability to dynamically adapt to network conditions, its multi-protocol tunneling capabilities, and the ease with which it can establish functional tunnels over otherwise restrictive network paths.

Defensive Implications

▶ Watch: Defensive recommendations for network security (47:00)

XFLTReaT, while a potent tool for offensive security, also offers significant value to defensive teams. Understanding its capabilities is crucial for both sides of the cybersecurity spectrum.

For Offensive Security (Red Teams):

  • Bypassing Obstacles: XFLTReaT provides red teams with a highly flexible tool to bypass basic and even sophisticated network obstacles. If a network only allows ICMP or DNS traffic, the framework can leverage these to establish full tunnels, enabling C2 communication or data exfiltration.
  • Custom Protocol Support: The modular nature allows red teams to quickly implement support for niche or custom protocols (e.g., a specific HTTP header requirement for a proxy, or even out-of-band methods like SMS tunneling) to exploit unique network configurations.
  • Data Exfiltration: While full stack tunnels can be noisy, XFLTReaT can be used for data exfiltration. Its primary strength lies in establishing a full communication channel, allowing for interactive control and data transfer. For stealthier exfiltration, other specialized tools might be preferred, but XFLTReaT offers a robust alternative when noise is less of a concern.
  • Unfiltered Internet Access: In situations like captive portals at airports or restrictive corporate guest networks, XFLTReaT can provide unfiltered internet access by leveraging open protocols, demonstrating a common attack vector for initial foothold or lateral movement.

For Defensive Security (Blue Teams):

  • Network Weakness Identification: Blue teams can deploy XFLTReaT externally and use its --check functionality to map their own network's egress filtering capabilities. This can reveal unexpected open ports or protocols (like ICMP or DNS) that could be exploited by attackers, allowing defenders to proactively patch these weaknesses.
  • Proactive Breach Simulation: Organizations should actively attempt to exfiltrate data from their own networks using tools like XFLTReaT. If a blue team can successfully exfiltrate data, it indicates a potential breach vector that needs immediate attention. Being the first to discover such a vulnerability is paramount.
  • Captive Portal Hardening: For guest networks or captive portals, ensure that:
  • All internal client-to-client communication is dropped.
  • All external outbound packets (except for authenticated users) are dropped.
  • All DNS responses are rewritten to redirect to the captive portal's IP address, preventing DNS tunneling bypasses for unauthenticated users.
  • TCP connections can also be redirected to the captive portal.

General Defensive Recommendations:

Bucsay provided several actionable recommendations for improving overall network security posture against tunneling and exfiltration:

  1. Enforce Proxy Servers:
  • All internal clients (workstations, laptops, servers) should be mandated to use proxy servers for external internet access.
  • Proxies should primarily whitelist ports 80 (HTTP) and 443 (HTTPS). Any other required ports should be explicitly justified and configured.
  • While blacklisting can be done, it's less effective against sophisticated tunneling techniques. Whitelisting is preferred.
  1. Internal-Only DNS:
  • Clients should only be able to resolve internal DNS queries.
  • External DNS resolution should be handled exclusively by the proxy servers, preventing direct DNS queries that could be abused for tunneling.
  1. Maintain a Comprehensive Inventory:
  • An up-to-date inventory of all network assets is critical. This should include IP addresses, owners, physical locations, purpose, and contact information.
  • Such an inventory enables rapid response if malicious activity is detected on a specific host.
  1. Baselining with NetFlow/Bro:
  • Implement NetFlow or Bro (now Zeek) to collect network flow data.
  • Use this data to create a statistical baseline of "normal" network traffic, identifying top talkers, typical protocols, communication frequencies, and data volumes.
  • Configure alerts for any deviations from this baseline. False positives can be incorporated into the baseline, while genuine anomalies trigger investigations. This helps detect unusual traffic patterns indicative of tunneling or exfiltration.

By adopting these defensive strategies, organizations can significantly enhance their ability to detect, prevent, and respond to advanced tunneling techniques employed by adversaries or red teams.

Key Takeaways

  • Unified, Modular Tunneling: XFLTReaT is a Python-based, object-oriented framework that consolidates diverse tunneling protocols (TCP, UDP, ICMP, DNS, HTTP CONNECT, SCTP, WebSockets) into a single, extensible platform, simplifying deployment and management.
  • Addresses Existing Tool Limitations: It overcomes the fragmentation, difficulty of modification, and lack of support common in traditional, protocol-specific tunneling tools, offering a modern, adaptable alternative.
  • Automated Network Reconnaissance: The --check functionality allows users to quickly identify open and viable tunneling protocols on a network, providing invaluable insights for bypassing restrictions or assessing network vulnerabilities.
  • Flexible Architecture: XFLTReaT's design separates data and control channels and provides a unified virtual interface, making it easy to develop new tunneling modules and reuse existing code across different protocols.
  • Dual-Use Tool: Highly valuable for both offensive security (bypassing firewalls, exfiltrating data, gaining unfiltered internet access) and defensive security (identifying network weaknesses, simulating breaches, hardening network policies).
  • Ongoing Development & Community Contribution: The framework is actively developed, with planned features like encryption, broader OS support, and new modules. Community contributions are encouraged to enhance its capabilities.

About the Speaker(s)

Balazs Bucsay is a Senior Security Consultant at NCC Group, bringing a wealth of experience in offensive security. A Hungarian hacker now residing in the UK, Bucsay's passion for low-level technical work began at the age of 13 in 2000. He holds several strictly technical certifications and was pursuing the OSCE (Offensive Security Certified Expert) at the time of this talk. His previous notable projects include GI John, a distributive patch for John the Ripper released in 2009, and chroot, an open-source tool for breaking out of chroot environments, released two years prior to this presentation. XFLTReaT represents his latest major research project, which he had previously presented at other conferences such as Shakacon, Hawaii, and Hack in the Box GSEC in Singapore, continuously evolving the tool and presentation content.

Reviews

→ Top-rated talks at BruCON 0x09

All talks from BruCON 0x09