AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

i365Finds Editorial is the independent research and editorial organization behind 365 Wiki. We follow changes in tools, products, services, entertainment, and digital life around the world, turning scattered and fast-moving information into clearly sourced, well-structured public content that is easier to understand and compare.
Indexed 89,622 Wiki articles

How WebRTC Leaks Happen Through a Connected VPN

Bruno Ribeiro · 365Finds Editorial

A connected VPN does not automatically protect your public IP address from your web browser.

You turn on a VPN client, watch the status icon turn green, and check a standard IP lookup site. It shows an IP in Zurich or Reykjavik. You assume your traffic is sealed inside an encrypted tunnel. Yet open a webpage running a few lines of vanilla JavaScript, and the site can log your true ISP public IP address in milliseconds.

At 365Finds, we consider this one of the most jarring disconnects between consumer privacy expectations and browser networking realities. It is called a WebRTC leak. It is not an encryption crack, nor is it a tunnel crash. It is a browser feature working exactly as engineered—at the direct expense of your operational privacy.

+-------------------------------------------------------------------------+
|                              Host Operating System                      |
|                                                                         |
|  +--------------------+                     +------------------------+  |
|  | Physical Adapter   | (192.168.1.50)      | VPN Virtual Adapter    |  |
|  | (Wi-Fi / Ethernet) |                     | (TUN/TAP / Wintun)     |  |
|  +---------+----------+                     +-----------+------------+  |
|            |                                            |               |
|            | Socket bound to physical IP                | Default Route |
|            | (Bypasses VPN routing table)               | (Encrypted)   |
|            v                                            v               |
|    Outbound UDP STUN                            Regular Web Traffic     |
|   (Bypasses VPN Tunnel)                         (Enters VPN Tunnel)     |
+------------+--------------------------------------------+---------------+
             |                                            |
             v                                            v
     [ ISP Router / Gateway ]                     [ VPN Server Node ]
             |                                            |
             v                                            v
     [ STUN Server ]                              [ Target Website ]
   Reflects real ISP IP                           Sees VPN exit IP

The Peer-to-Peer Mandate: Why WebRTC Ignores Routing Conventions

Web Real-Time Communication (WebRTC) exists so browsers can exchange low-latency voice, video, and data streams directly between peers without bouncing every packet through a central media relay. Relaying 4K video through intermediaries costs immense server bandwidth. Direct peer-to-peer (P2P) connections solve that economic problem.

However, the modern internet is blanketed by Network Address Translation (NAT) gateways, stateful firewalls, and carrier-grade NATs. Two residential browsers cannot simply send packets directly to each other's private 192.168.x.x addresses.

To overcome this, WebRTC relies on the Interactive Connectivity Establishment (ICE) protocol (RFC 8445) and Session Traversal Utilities for NAT (STUN, RFC 8489). Before establishing a media channel, the browser's ICE agent must discover every possible network path over which it could conceivably talk to the remote peer.

These paths are cataloged as ICE candidates:

  1. Host candidates: Addresses directly bound to local network adapters (both physical and virtual).
  2. Server-reflexive (srflx) candidates: The host's public IP and port as observed from the outside world by an external STUN server.
  3. Relay candidates: Public addresses provided by a Traversal Using Relays around NAT (TURN) server when direct peer traversal fails.

Here is the crux: to find the fastest direct path, the browser does not just query through the operating system's default route. It queries across all available network interfaces.

The Mechanics of the Leak: Socket Binding and Multi-Homing

When a VPN connects, it creates a virtual network interface (such as a TUN/TAP adapter on Windows, utun on macOS, or a WireGuard virtual adapter). It then updates the operating system's routing table, directing general outbound traffic (0.0.0.0/0 or split 0.0.0.0/1 and 128.0.0.0/1) into the virtual tunnel.

Standard HTTP requests generated by the browser obey this default route. The operating system receives a generic TCP socket request, inspects its routing table, and shunts the traffic into the VPN adapter.

WebRTC does something entirely different. Modern operating systems are multi-homed: your physical Wi-Fi or Ethernet adapter remains active alongside the VPN adapter. Because the ICE framework prioritizes discovering every conceivable route, the browser enumerates all local network interfaces.

Webpage JavaScript -> RTCPeerConnection -> ICE Agent initiates STUN query
                                              |
                   +--------------------------+--------------------------+
                   |                                                     |
                   v                                                     v
      Socket 1 (Default Route)                              Socket 2 (Physical Interface)
      Routes to VPN Adapter                                Explicitly bound to local NIC IP
                   |                                                     |
                   v                                                     v
          Encrypted Tunnel                                    Plaintext Outbound UDP
                   |                                                     |
                   v                                                     v
          VPN Exit Node (Zurich)                              ISP Gateway (Real IP)
                   |                                                     |
                   v                                                     v
         STUN Server receives request                        STUN Server receives request
       Reflects Zurich IP back                             Reflects Real ISP IP back
                   |                                                     |
                   +--------------------------+--------------------------+
                                              |
                                              v
                              Browser receives both ICE candidates
                              JavaScript executes onicecandidate:
                              -> Extracts and logs your Real ISP IP

Instead of opening a generic socket and leaving interface selection to the OS routing table, the ICE agent creates UDP sockets explicitly bound to the IP address of the physical adapter. In networking, explicit socket binding overrides generic routing table rules.

The browser sends a STUN Binding Request packet directly out through your physical Wi-Fi adapter to an external STUN server (frequently hosted by Google or public STUN operators). That packet never touches the VPN tunnel. It hits your home router, crosses your ISP's infrastructure, and arrives at the STUN server carrying your raw, unmasked public IP address in the UDP header.

The STUN server reads the source IP of the packet and echoes it back inside a STUN Binding Success Response (XOR-MAPPED-ADDRESS attribute). The response re-enters your physical adapter. The browser unwraps it, generates an srflx ICE candidate containing your actual ISP IP, and exposes that candidate string to the page's JavaScript via the RTCPeerConnection.onicecandidate callback.

A site does not need permissions to read this. It does not prompt for camera or microphone access. A hidden script on any commercial webpage can initiate an empty RTCPeerConnection, gather ICE candidates, parse the text string, and send your true IP to an analytics server in under 200 milliseconds.

Why mDNS Protects Local IPs but Leaves Public IPs Exposed

Readers often ask us at 365Finds whether mDNS (Multicast DNS) solves this issue. It only solves half of it.

In older browser builds, WebRTC exposed private local IP addresses (like 192.168.1.105 or 10.0.0.15) in host candidates. Malicious actors used these local IPs for internal LAN fingerprinting and tracking users across browser sessions.

Modern browsers mitigate this local exposure by generating randomized mDNS hostnames (such as d7a5b3f1-4c6e-4f12-9b28.local) for host candidates. The browser conceals your internal LAN topology from untrusted JavaScript.

However, mDNS does nothing to stop server-reflexive (srflx) candidate generation. When the ICE agent sends a UDP STUN packet over the physical adapter to an external internet host, the public IP reflected back is your genuine WAN address. The mDNS privacy standard intentionally does not mask external STUN reflections because masking them would break peer connectivity across the open internet.

The IPv6 Blind Spot

The second major WebRTC leak mechanism involves dual-stack network configurations. Many residential ISPs assign both an IPv4 address and a globally routable IPv6 prefix.

Many VPN providers, however, still route IPv4 exclusively. To prevent IPv6 leaks, competent VPN clients either route IPv6 through their own servers or disable the IPv6 stack on physical network adapters while connected.

Budget or poorly engineered VPN clients do neither. They establish an IPv4 tunnel, adjust IPv4 routes, and ignore IPv6 entirely.

When your browser loads a webpage, WebRTC launches ICE probes over both IPv4 and IPv6. If the VPN client left IPv6 active on the physical network card without a default tunnel route, the browser sends STUN requests over the native IPv6 connection. Because IPv6 addresses are globally unique and end-to-end routable, the STUN server reflects your device's actual IPv6 address straight into the browser.

The website then holds an immutable, hardware-linked address pointing directly to your residential internet subscription.

The Role of Split Tunneling and Weak Kill Switches

WebRTC leaks thrive under two common VPN client conditions: split tunneling and weak routing enforcement.

1. Split Tunneling

Split tunneling allows users to route specific apps through the VPN while allowing other apps to use the local ISP connection. When split tunneling operates at the application level, the operating system maintains routing tables and socket bindings for both interfaces simultaneously. If the browser or its underlying network daemon is not strictly bound to the virtual interface, WebRTC's aggressive multi-interface probing will seek out the physical adapter and bypass the tunnel.

2. Lack of Kernel-Level Firewall Rules

Many basic VPN apps manage network traffic purely by adding and removing OS route entries (route add commands). They do not configure the Windows Filtering Platform (WFP), macOS Packet Filter (pf), or Linux nftables/iptables.

A routing table entry is a recommendation that applications can override with explicit socket bindings. A kernel-level firewall rule, by contrast, is an absolute restriction. If a VPN client does not block outbound UDP traffic on non-VPN physical adapters at the firewall layer, socket-bound STUN packets easily slip past.

VPN MechanismHow Routing OperatesWebRTC ResistanceFailure Mode
Pure Route ModificationAdds low-metric routes pointing to VPN virtual adapterPoorSocket bound to physical adapter IP bypasses route table
Application Split TunnelDual active interfaces with policy routing rulesVery PoorBrowser enumerates unencrypted interface; sends native STUN queries
Kernel Firewall Kill Switch (WFP / nftables)Drops all outbound packets on physical adapters except to VPN server IPStrongSTUN queries sent to physical adapter are dropped before leaving the device
Router-Level VPN TunnelEntire physical interface connects to an upstream VPN routerCompleteLocal device has no native ISP interface; physical socket binding is impossible

Technical Remediation: How to Block WebRTC Leaks

Relying solely on a desktop VPN toggle is insufficient if the client lacks low-level packet filtering. We at 365Finds recommend tackling WebRTC leaks at the browser and protocol layers.

1. Chromium Policy Enforcement (RFC 8828)

Chromium browsers (Google Chrome, Microsoft Edge, Brave, Opera, Vivaldi) implement IETF RFC 8828 IP handling policies through the WebRtcIPHandling policy setting:

To enforce this in Chrome on Windows, configure the registry key: HKLM\SOFTWARE\Policies\Google\Chrome\WebRtcIPHandling as a REG_SZ with value default_public_interface_only or disable_non_proxied_udp.

Alternatively, privacy extensions such as WebRTC Leak Prevent or uBlock Origin ("Prevent WebRTC from leaking local IP address") adjust this exact browser preference without manual registry edits.

2. Firefox Configuration

Firefox offers direct control over ICE candidate handling via about:config:

3. Brave Browser

Brave provides a native user interface toggle under Settings -> Privacy and security -> WebRTC IP handling policy. Selecting Disable non-proxied UDP enforces RFC 8828 Mode 4, preventing direct UDP interface enumeration while maintaining compatibility with TURN-relayed media.

4. Router-Level VPN Encapsulation

The most robust architectural solution eliminates multi-homing at the host level entirely. By installing your VPN client on a dedicated router or hardware firewall (such as OpenWrt, pfSense, or OPNsense), your computer’s physical network adapter only ever sees the router’s local subnet.

Even if WebRTC binds directly to your computer's physical adapter, the only gateway it can reach is the router, which encapsulates every outbound packet into the encrypted tunnel before it ever touches your ISP line.

When a browser initiates an ICE gathering phase, it issues a getStats() or RTCIceCandidate payload containing candidate attributes. In an unprotected browser on a standard VPN, the result looks like this:

candidate:842163049 1 udp 1686052607 203.0.113.45 58321 typ srflx raddr 192.168.1.50 rport 58321

The IP 203.0.113.45 is not the Zurich VPN address. It is the raw IP assigned by your local internet service provider.

References