From DNS Evasion to Deep Packet Inspection

Across this three-part series, we tested what network defenses actually see when a WebRTC DataChannel acts as a bounded application proxy:

  • Part 1 showed that client-side DNS filters (like NextDNS) never fire when a remote WebRTC peer resolves the destination.
  • Part 2 built a reproducible lab pinning Coturn 4.12.0, mitmproxy 12.2.3, Suricata 8.0.5, and Zeek 8.0.8.
  • Part 3 covers the P2-A through P2-F test results, explains why explicit proxies miss WebRTC while transparent L7 inspection catches it, looks at ALPN spoofing and ECH, and shares working Suricata and EDR rules.

Empirical Test Matrix Results (P2-A through P2-F)

For every test run, we logged the selected ICE candidate pair, Coturn allocation state, and HTTP response status:

+------+-----------+-----------------------------------+-------------------+------------------------------+
| ID   | ICE Mode  | Transport / Candidate Path        | Inspection State  | Verified Outcome             |
+------+-----------+-----------------------------------+-------------------+------------------------------+
| P2-A | all       | Direct host / server-reflexive    | Off               | Complete (Passed - HTTP 200) |
| P2-B | all       | Direct host / server-reflexive    | On (mitmproxy)    | Bypasses explicit proxy      |
| P2-C | relay     | TURN UDP (:3478)                  | Off               | Complete (Passed - HTTP 200) |
| P2-D | relay     | TURN UDP (:3478)                  | On (mitmproxy)    | Bypasses explicit proxy      |
| P2-E | relay     | turns: TLS/TCP (:443)             | Off               | Complete (Passed - HTTP 200) |
| P2-F | relay     | turns: TLS/TCP (:443)             | On (mitmproxy)    | Bypasses explicit proxy      |
+------+-----------+-----------------------------------+-------------------+------------------------------+
  • Direct Host (P2-A / P2-B): With ICEPolicy=all, Pion WebRTC picked (local) udp4 host 192.168.56.1:51017 <-> (remote) udp4 host 192.168.56.1:51012 and brought up the DTLS DataChannel over UDP in under 800ms.
  • TURN UDP/TCP (P2-C / P2-D): LAB_ICE_POLICY=relay forced allocations through Coturn (ALLOCATE, CREATE_PERMISSION, CHANNEL_BIND on :3478), selecting (local) udp4 relay 127.0.0.1:49161 <-> (remote) udp4 relay 127.0.0.1:49189. Inner payloads stayed DTLS-encrypted, while outer STUN headers were plaintext on port 3478.
  • TURNS over TLS 1.3 (P2-E / P2-F): turns:turn.lab.example:443?transport=tcp wrapped the entire TURN and DTLS exchange inside TLS 1.3 to Coturn (mapped to internal port 5349), hiding STUN headers inside TLS Application Data.

Traffic Flow & Explicit vs. Transparent Proxies

Why did P2-B, P2-D, and P2-F sail right past mitmproxy when it ran as an explicit forward proxy?

Explicit proxies depend on apps honoring HTTP_PROXY / HTTPS_PROXY and sending an HTTP CONNECT host:443 request. WebRTC engines don't use HTTP CONNECT for media or DataChannel sockets—they open raw UDP or TCP sockets straight to the peer or TURN server.

Here is how traffic moves through explicit vs. transparent controls:

[ Client Process (webclient / browser) ]
   |
   +-- 1. DNS Query for Target? -----> [ NONE: Offloaded to Remote Proxy Peer ] (Bypasses Local DNS Filter)
   |
   +-- 2. Explicit Proxy (HTTP_PROXY)? -> [ BYPASSED: WebRTC opens raw UDP/TCP socket; no HTTP CONNECT sent ]
   |
   v
[ Network Perimeter / Egress Firewall ]
   |
   +-- Path A: Direct UDP / TURN UDP (:3478) ---> Blocked if Egress UDP is denied; otherwise passes uninspected
   |                                              (Default Suricata logs app_proto: "failed", 0 alerts)
   |
   +-- Path B: TURNS TLS 1.3 (:443 over TCP)
          |
          +--> [ Passive NDR (Zeek / Suricata) ]
          |       +-- Standard TLS 1.3: Zeek ssl.log extracts plaintext SNI ("turn.lab.example")
          |       +-- With ECH (RFC 9460): Outer SNI shows benign CDN; Inner TURN SNI is encrypted
          |
          +--> [ Transparent Inline TLS Inspector (SSL Bump) ]
                  +-- Checks ALPN: Rejects "webrtc-turn" if strict HTTP allowlist is enforced
                  +-- If ALPN Spoofed as "h2": Decrypts TLS -> Expects RFC 9113 24-byte HTTP/2 Preface
                  +-- Sees binary STUN (0x2112A442) instead of "PRI * HTTP/2.0" -> Sends GOAWAY / TCP RST

ALPN Spoofing vs. Layer 7 Protocol Validation

What if an attacker controls the Coturn server and configures it to advertise h2 or http/1.1 in TLS ALPN to fool handshake-level checks?

  • HTTP/2 parsing (RFC 9113): Right after the TLS handshake, a real HTTP/2 client must send the 24-byte preface (PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n) followed by a SETTINGS frame. When WebRTC sends binary STUN frames instead (0x0003 ALLOCATE, magic cookie 0x2112A442), an inline HTTP/2 parser kills the stream with PROTOCOL_ERROR / GOAWAY.
  • HTTP/1.1 parsing: An HTTP/1.1 parser expects ASCII (GET / HTTP/1.1) and drops binary STUN with HTTP 400 Bad Request or TCP RST.

Takeaway: Checking ALPN at the handshake is easy to spoof. Effective inline inspection needs post-handshake Layer 7 protocol validation.

The Next Evasion Frontier: Encrypted Client Hello (ECH)

In our passive tests, Zeek's ssl.log caught "server_name":"turn.lab.example" on port 443 because standard TLS 1.3 sends SNI in plaintext. Encrypted Client Hello (ECH, RFC 9460) hides that signal:

  • How it works: ECH splits the handshake into a plaintext Outer ClientHello (showing a shared CDN domain) and an encrypted Inner ClientHello (holding the real turn.lab.example SNI), encrypted with a key from DNS type 65 (HTTPS / SVCB) records.
  • How to defend against it: Strip or filter DNS type 65 (HTTPS / SVCB) responses at corporate resolvers so clients fall back to plaintext SNI, and enforce transparent TLS inspection on port 443 (which rejects external ECH).

Sensor Telemetry & Validated Suricata Signatures

Replaying the lab PCAPs through offline (--network none) Zeek 8.0.8 and Suricata 8.0.5 containers exposed a clear NIDS blind spot:

  • Zeek 8.0.8: Logged all 8 sessions in conn.log, captured cleartext broker signaling in http.log (POST /session/session-P2-A/offer on :18080), and extracted "server_name":"turn.lab.example" in ssl.log.
  • Default Suricata 8.0.5: Marked all TURN UDP (:3478) and WebRTC DTLS traffic as app_proto: "failed" and raised zero alerts.

To fix that, we wrote and tested three custom rules in rules/webrtc_part2.rules:

# Rule 1: STUN Magic Cookie in UDP header (RFC 5389 magic cookie 0x2112A442 at byte offset 4)
alert udp any any -> any any (msg:"ET INFO WebRTC/STUN Message Observed (Magic Cookie)"; content:"|21 12 a4 42|"; offset:4; depth:4; classtype:policy-violation; sid:1000001; rev:1;)

# Rule 2: DTLS 1.2 Record Layer Handshake header (type=0x16, version=0xFEFD DTLS 1.2)
alert udp any any -> any any (msg:"ET INFO WebRTC DTLS 1.2 Handshake Record"; content:"|16 fe fd|"; offset:0; depth:3; classtype:policy-violation; sid:1000002; rev:1;)

# Rule 3: TLS SNI for unauthorized TURN infrastructure
alert tls any any -> any 443 (msg:"ET POLICY WebRTC turns: Connection to Lab TURN Realm"; tls.sni; content:"turn.lab.example"; classtype:policy-violation; sid:1000003; rev:1;)

Replaying the capture with those rules produced 25 alerts in fast.log (21 STUN magic-cookie hits and 4 DTLS handshake hits).

Cutting noise in production: Teams, Zoom, and Webex all use STUN/UDP legitimately. In production, suppress published UC CIDR ranges (Teams 52.112.0.0/14, 52.120.0.0/14; Zoom 170.114.0.0/16; Webex 64.68.96.0/19), alert on STUN traffic hitting residential or VPS ASNs (DigitalOcean, Hetzner, Linode, Vultr), and pair network alerts with endpoint process data.

Endpoint Telemetry & EDR Hunting Primitives

On a corporate endpoint, WebRTC sockets should almost always come from signed browsers (chrome.exe, msedge.exe, firefox.exe) or meeting apps (teams.exe, zoom.exe). A standalone binary opening STUN/DTLS sockets is a strong EDR signal:

+-----------------------+-----------------------------+---------------------------------------------------------------+
| Telemetry Source      | EDR / Sysmon Artifact       | Detection Primitive & Hunting Logic                           |
+-----------------------+-----------------------------+---------------------------------------------------------------+
| Process Execution     | Sysmon EID 1                | Process.Signature != 'Valid' (unsigned or ad-hoc self-signed) |
| File Path & Name      | Process.Executable          | Executable path is outside C:\Program Files\ (e.g., Temp/App) |
| Parent Process Lineage| ParentProcess.Executable    | Spawned by script interpreter (powershell.exe, cmd.exe)      |
| Outbound UDP Sockets  | Sysmon EID 3 (Network)      | Initiates UDP connection to port 3478 or high ephemeral ports |
| Binary Name Filtering | Process.OriginalFileName    | Process is NOT in allowlist (chrome, msedge, teams, zoom)    |
| Module Loading        | Sysmon EID 7 (ImageLoad)    | Absence of standard browser multimedia DLLs (mfplat, webrtc)  |
+-----------------------+-----------------------------+---------------------------------------------------------------+
title: Standalone Non-Browser Process Initiating WebRTC/STUN Socket
status: experimental
description: Detects non-browser and non-conferencing processes initiating outbound UDP traffic to TURN (3478) or WebRTC ports.
logsource:
  category: network_connection
  product: windows
detection:
  selection:
    DestinationPort:
      - 3478
      - 5349
    Protocol: udp
  filter_authorized_apps:
    Image|endswith:
      - '\chrome.exe'
      - '\msedge.exe'
      - '\teams.exe'
      - '\zoom.exe'
      - '\webex.exe'
  condition: selection and not filter_authorized_apps

Controls Comparison Matrix & Blue Team Blueprint

Putting Parts 1–3 together gives the full defensive picture:

+---------------------------+-------------------+-----------------+---------------------------------------------------------------+
| Control Layer             | Target Tested     | Outcome         | Defensive Reality                                             |
+---------------------------+-------------------+-----------------+---------------------------------------------------------------+
| Client-Side DNS Filter    | All modes         | Ineffective     | Monitored client never issues a DNS query for the target.     |
| Egress UDP Filter         | Direct & TURN UDP | Effective       | Drops outbound UDP, preventing P2-A and P2-C from connecting. |
| Egress TCP Filter         | TURN TCP (:3478)  | Effective       | Blocking non-web ports stops unencrypted TURN TCP relays.     |
| Explicit Forward Proxy    | All modes         | Ineffective     | Direct socket communication bypasses HTTP CONNECT proxies.   |
| Transparent NGFW (L7)     | turns: (:443)     | Effective       | Non-HTTP ALPN / binary data fails strict L7 HTTP parsing.     |
| SNI Domain Filtering      | turns: (:443)     | Effective       | TLS ClientHello exposes SNI (unless ECH is employed).         |
| Default NIDS (Suricata)   | All UDP modes     | Ineffective     | Classifies DTLS/STUN as unclassified (app_proto: failed).     |
| Tuned NIDS Signatures     | STUN / DTLS / SNI | High Visibility | Flags STUN magic cookies (0x2112A442) with CIDR suppression.  |
| Endpoint Process Analysis | Non-browser exec  | High Visibility | Standalone Go binary initiating STUN is a clear EDR anomaly.  |
+---------------------------+-------------------+-----------------+---------------------------------------------------------------+

Blue Team Checklist:

  • 1. Block unapproved outbound UDP at the firewall (allow only corporate DNS and approved UC ranges).
  • 2. Enforce transparent L7 HTTP/2 validation and SNI allowlisting on port 443, and strip DNS type 65 (HTTPS) records to avoid ECH blind spots.
  • 3. Deploy STUN (|21 12 a4 42|) and DTLS (|16 fe fd|) NIDS rules with UC CIDR exclusions.
  • 4. Hunt in EDR for unsigned or non-browser binaries opening UDP/TCP sockets to TURN or ephemeral peer ports.

Repository: View the snowflake-inspired-webrtc-proxy-lab on GitHub (FINDINGS_PART2.md and rules/).