Back to Blog

Detecting RDP Tunneling via TCP Packet Inter-MTU and Inter-Arrival Time Analysis

Detecting RDP Tunneling via TCP Packet Inter-MTU and Inter-Arrival Time Analysis

In the modern enterprise, the perimeter is increasingly porous. While traditional Deep Packet Inspection (DPI) has long been the gold standard for identifying unauthorized protocols, the widespread adoption of TLS 1.3 and sophisticated tunneling techniques has rendered payload-based inspection increasingly obsolete. Attackers and unauthorized users now frequently bypass egress filtering by encapsulating Remote Desktop Protocol (RDP) traffic within seemingly benign streams, such as HTTPS (via WebSockets) or SSH.

Because the payload is encrypted, signature-based detection fails. To identify these "hidden" sessions, we must shift our focus from what is being sent to how it is being sent. This brings us to the domain of side-channel analysis: specifically, analyzing the statistical properties of TCP Packet Inter-Arrival Time (IAT).

The Anatomy of RDP Traffic Patterns

To detect an anomaly, one must first define the baseline. RDP is an inherently interactive, asynchronous protocol. Its traffic profile is characterized by a distinct, non-uniform distribution of packet timings and sizes, driven by human-computer interaction (HCI):

  1. Input Bursts (Low Volume, Low IAT): Keystrokes and mouse movements generate small, frequent packets. These often arrive in rapid succession (low IAT) with minimal payload size.
  2. Screen Updates (High Volume, High IAT): When a window changes or a screen refreshes, the server pushes large bursts of data. These packets are typically larger (approaching the Maximum Segment Size, or MSS) and are often separated by larger temporal gaps as the client processes the frame.
  3. Keep-Alives (Periodic, Constant IAT): RDP maintains session persistence through periodic, small, highly predictable packets.

This "bursty" nature creates a specific statistical fingerprint. The inter-arrival time-the delta between the timestamp of packet $n$ and packet $n-1$-follows a distribution that is significantly different from a continuous file download (which is highly regular) or a streaming video (which is buffered and smoothed).

The Impact of Tunneling on Temporal Dynamics

When RDP is tunneled through another protocol (e.g., an SSH tunnel or an HTTPS proxy), the underlying TCP stream undergoes a transformation. The "wrapper" protocol introduces several mechanical artifacts that alter the IAT:

1. Encapsulation Overhead and Jitter

Tunneling adds additional headers (e.g., SSH framing or TLS record layers). While this primarily affects packet size, the process of encapsulation often involves secondary buffering. As the outer protocol manages its own congestion control and window scaling, it introduces "jitter"-artificial variance in the IAT that deviates from the native RDP behavior.

2. Buffering and Packet Coalescing

Many tunneling proxies or web gateways do not forward packets immediately. To optimize throughput, they may employ "Nagle-like" algorithms, buffering smaller RDP input packets to coalesce them into a single larger encrypted segment. This effectively "smears" the high-frequency, low-IAT keystroke bursts, making them appear more rhythmic and less interactive.

3. Protocol Flattening

The most significant indicator of tunneling is the "flattening" of the distribution. The distinct peaks in the IAT histogram-the sharp distinction between the "input" phase and the "update" phase-tend to merge. The statistical variance of the IAT decreases as the tunneling layer imposes its own pacing on the encapsulated stream.

Methodology for Detection

Detecting these shifts requires a structured approach to feature engineering and statistical modeling.

Feature Extraction

A robust detection engine should extract the following features from a captured TCP flow:

  • Mean and Variance of IAT: To measure the stability of the stream.
  • Coefficient of Variation ($CV$): Calculated as $\sigma / \mu$ (standard deviation divided by the mean). A lower $CV$ often indicates a more "smoothed" or tunneled stream.
  • Skewness and Kurtosis: To capture the "tailedness" of the bursts. RDP naturally has high skewness due to the disparity between keystrokes and screen updates.
  • Packet Size Entropy: Measuring the randomness of the distribution of packet lengths.

Implementation Pipeline

  1. Ingestion: Utilize `tshark` or `zeek` to extract packet timestamps and lengths from network flows (NetFlow/IPFIX or PCAP).
  2. Windowing: Analyze traffic in sliding temporal windows (e.g., 30-second intervals). Analyzing a single packet is useless; analyzing a 10-minute window may be too slow for real-time detection.
  3. Statistical Profiling: Compute the $CV$, Skewness, and Kurtosis for each window.
  4. Classification: Use a trained model (such as a Random Forest classifier or an Isolation Forest for anomaly detection) to compare the current window's features against a known-good RDP baseline.

Practical Example: Python-based Feature Extraction

Using `scapy`, one can prototype the extraction of IAT features as follows:

```python

from scapy.all import rdpcap

import numpy as np

def analyze_flow(pcap_file):

packets = rdpcap(pcap_file)

Extract timestamps of TCP packets

timestamps = [float(pkt.time) for pkt in packets if pkt.haslayer('TCP')]

if len(timestamps) < 2:

return None

Calculate Inter-Arrival Times (IAT)

iat = np.diff(timestamps)

features = {

"mean_iat": np.mean(iat),

"std_iat": np.std(iat),

"cv_iat": np.std(iat) / np.mean(iat) if np.mean

```

Conclusion

As shown across "The Anatomy of RDP Traffic Patterns", "The Impact of Tunneling on Temporal Dynamics", "Methodology for Detection", a secure implementation for detecting rdp tunneling via tcp packet inter-mtu and inter-arrival time analysis depends on execution discipline as much as design.

The practical hardening path is to enforce strict token/claim validation and replay resistance, certificate lifecycle governance with strict chain/revocation checks, and host hardening baselines with tamper-resistant telemetry. This combination reduces both exploitability and attacker dwell time by forcing failures across multiple independent control layers.

Operational confidence should be measured, not assumed: track detection precision under peak traffic and adversarial packet patterns and policy-gate coverage and vulnerable artifact escape rate, then use those results to tune preventive policy, detection fidelity, and response runbooks on a fixed review cadence.

Related Articles

Explore related cybersecurity topics:

Recommended Next Steps

If this topic is relevant to your organisation, use one of these paths: