ICMP tunnelling

term

securitynetworking

Kept in this browser · My desk

Carrying data or commands in the payload of ICMP messages, usually echo requests and replies, which many networks pass without looking inside.

The ICMP specification requires an echo reply to return the echo's data unchanged and says nothing about what the data may be. Project Loki, published in Phrack in 1996, described the channel and LOKI2 (1997) implemented it with encryption; MITRE lists malware families that use ICMP for command and control.

How it works. An Internet Control Message Protocol (ICMP) echo message, type 8, and its echo reply, type 0, carry a code of 0, a checksum, a 16-bit identifier, a 16-bit sequence number and then data of any length. Request for Comments (RFC) 792 (September 1981) says the data received in an echo must be returned in the reply, and RFC 1122 (October 1989) made the rule stricter: every host must implement an echo server, and data received in an echo request must be entirely included in the reply, truncated only where sending it would need fragmentation that is not implemented. Neither standard says what the data may be. A tunnel client therefore puts its traffic in the data of echo requests, a server outside answers with replies whose data carry the return traffic, and a firewall that passes ping without looking inside passes the conversation. Because the outside party speaks only when the inside client asks, tools keep a steady stream of requests going to poll for commands.

History. In Phrack 49, in a file dated August 1996, daemon9 (also known as route) and Alhambra published Project Loki: arbitrary information could ride in echo and echo reply data, a form of steganography in their words; detection would be hard if traffic stayed low and the server hid in the kernel; a surplus of echo replies with garbled payloads was the clue; accepting echo only from trusted hosts was useless because source addresses can be forged; and the only sure cure was to deny all incoming echo. LOKI2, in Phrack 51 of 1 September 1997, tunnelled shell commands in ICMP echo and in Domain Name System (DNS) messages, with Blowfish and a Diffie-Hellman key exchange, a weak XOR (exclusive or) or no encryption, and could swap protocols on the fly. By 2006 the Centro de Atendimento a Incidentes de Segurança (CAIS) of Brazil's Rede Nacional de Ensino e Pesquisa (RNP) listed ICMPTX, itun, PingTunnel and ptunnel, which carry whole Internet Protocol (IP) connections over echo types 0 and 8, and gave a detection hint: the magic number 0xD5200880 that identifies ptunnel.

In the wild. MITRE ATT&CK (Adversarial Tactics, Techniques, and Common Knowledge) files ICMP command and control under non-application-layer protocols, T1095, with PingPull, PHOREAL and COATHANGER among its procedure examples, and notes that ICMP is less commonly monitored than the Transmission Control Protocol (TCP) or the User Datagram Protocol (UDP). Palo Alto Networks' Unit 42 described PingPull on 13 June 2022 as a remote access trojan of GALLIUM, a group it assesses as likely Chinese state-sponsored, with variants for ICMP, for the Hypertext Transfer Protocol (HTTP) and its secure form HTTPS, and for raw TCP. The ICMP variant beacons with echo requests whose data hold, in some samples, a hard-coded 8-byte value, then the letter R, a sequence number for messages too long for one packet, an identifier beginning PROJECT, total and current lengths and data encrypted with the Advanced Encryption Standard (AES) and encoded in Base64; the server issues commands in echo replies. Wojciech Mazurczyk and Luca Caviglione describe Regin, disclosed in November 2014, as tunnelling secrets in ICMP ping traffic as well as in HTTP cookies.

What a normal ping looks like. Windows ping sends 32 bytes of data by default and accepts up to 65,500; iputils ping on Linux sends 56 data bytes by default, 64 with the 8-byte ICMP header, starting with a timestamp structure followed by pad bytes, of which the user may set at most 16 with -p. Echo payloads of other sizes, data that is not the fixed pattern of a ping program, long sustained echo exchanges with one external address and echo sent by a process that is not a diagnostic tool are the anomalies that separate a tunnel from troubleshooting. Signatures catch known tools, as Unit 42's Threat Prevention signatures 86625 to 86627 do for PingPull; the anomalies catch the rest.

Defences. Loki's authors advised denying all incoming echo, but dropping ICMP wholesale breaks path maximum transmission unit (MTU) discovery and diagnostics. RFC 4890 (May 2007) lists the ICMP version 6 (ICMPv6) messages a firewall must pass and warns in section 3.5 that error messages which must pass in both directions can carry a covert conversation or a tunnel, recommending deep packet inspection to check that the packet quoted inside an error belongs to legitimate traffic. Rate limits, size limits and alerts on echo payloads that ping programs do not send are the practical middle way. Normalization helps only at the margin: Cisco's inline normalization can clear the 8-bit code field of echo requests and replies, which removes a tiny storage channel but not a tunnel in the data. The strongest single clue is on the endpoint: which process sent the echo.

Neighbours. DNS tunnelling is the same idea in a protocol that the organization's own resolvers forward for the attacker; traceroute and path MTU discovery are the legitimate ICMP uses that wholesale blocking breaks; traffic normalization and deep packet inspection are the network controls, and exfiltration and command and control the purposes.

Also known as: icmp tunneling, icmp tunnel, ping tunnel, tunelamento icmp

Sources

← Back to I Back to the glossary