How to perform a VPN leak test
OK, so you’ve setup your VPN client. It runs, and there are no error messages. You can reach the Internet. But how can you ensure that all of your traffic is routed through the VPN tunnel? And even if everything seems OK now, what will happen if the machine sleeps, and then resumes? What if there’s an interruption in network connectivity? Or what if you’re using WiFi, and switch to a new access point and network? Or if you connect to a network that’s fully IPv6 capable? This guide demonstrates how you can conduct a comprehensive VPN leak test.
First, verify that your computer has configured a VPN tunnel. In Windows, open a command prompt, and run
ipconfig /all. You’ll see an ethernet adapter section with the Description “TAP-Windows Adapter V9”. The IPv4 Address will be something like
10.x.y.z. In OSX and Linux, open a terminal, and run
ifconfig. The VPN tunnel adapter is
utun0 in OSX, and
tun0 in Linux.
Risks from Browser Fingerprinting and IPv6 Leaks
The only way to know whether all traffic is using the VPN tunnel is through testing. But there is some risk in testing for VPN leaks. Browsers can be fingerprinted in various ways. And so sites that you use in testing may see the same browser fingerprints from both your ISP-assigned IP address and your VPN exit IP address. Any adversary that learned your browser’s fingerprints could later identify you, even if you were connecting through a VPN and/or Tor, as long as you were using the same browser. A recent W3C draft guidance states: “elimination of the capability of browser fingerprinting by a determined adversary through solely technical means that are widely deployed is implausible”.
WebGL fingerprinting and IPv6 leaks are far worse. WebGL uses the GPU via the OS graphics driver. On a given system, it appears that all browsers with WebGL enabled will have the same WebGL fingerprint. When using VPN services, I recommend blocking WebGL. In Firefox, for example, open “about:config” and toggle “webgl.disabled” to “true”. In NoScript options, check “Forbid WebGL” in the “Embeddings” tab.
It appears that systems using a given graphics driver can have the same WebGL fingerprint on hardware with a given GPU. So reinstalling a given OS, or even switching to another OS that uses the same graphics driver, won’t change the WebGL fingerprint. This is clearly the case for VirtualBox VMs using the default virtual GPU. For example, browsers on Debian and Lubuntu VMs have the same WebGL fingerprint. But browsers on other OS (unrelated Linux distros, FreeBSD, Windows and OSX) have different WebGL fingerprints. However, the host and VMs use different GPUs (real vs virtual) so there is no overlap in WebGL fingerprints.
It’s not uncommon for VPN clients to leak IPv6 traffic. That’s serious, because IPv6 addresses are typically device-specific. And so it’s prudent to disable IPv6 in both your OS and your LAN router. It’s also prudent to use VPN clients that block IPv6 traffic, or block IPv6 in your firewall. And whenever you first connect through a new LAN or WiFi network, check IPv6 connectivity.
By the way, WebGL fingerprinting is a crucial issue when compartmentalizing across multiple VMs. It’s true that you can easily block WebGL fingerprinting in browsers. But it’s also prudent to compartmentalize across VMs with different WebGL fingerprints. Whonix instances are another good option, because Tor browser has been hardened to fully block WebGL fingerprinting.
VPN Leak Test
While doing your VPN leak test, you can use tcpdump to check for traffic that’s not using the VPN tunnel. In Windows, you’ll need wintee. Just put a copy in your user folder. Now list network interface numbers:
You want the physical network interface. It’s typically “1”. So to start capturing:
Host a.b.c.d is the VPN server that you’re using. Keep the command/terminal window open while you do the following tests, and look for packets with addresses outside your local LAN and/or WiFi networks.
Start by checking your IP address. It’s safest to use your VPN provider’s website. If they don’t report IP address, the next safest bet is arguably check.torproject.org. If you intend to test for VPN leaks using other sites, I recommend using Tor browser, because it’s been hardened to block WebGL fingerprinting, and to otherwise report the same fingerprints for all users. But for now, it’s OK to use your default browser. Anyway, you should see your VPN exit IP address.
You also want an ongoing source of network traffic. In a second command/terminal window:
If you want pinging with timestamps in Windows or OSX, hacks (more or less ugly) are required:
<p> Linux: </p> <div> <pre><code class="language-none">ping -D -n a.b.c.d 2>&1 | tee ping.log</code></pre></p> <p> Custom clients of some VPN providers block pings to their servers through their VPN tunnels. If you see no output, hit Ctrl-C and try pinging a.b.c.1 instead. If that also doesn't work, try 22.214.171.124 (torproject.org). In the traffic capture window, you should see no packets with addresses outside your local LAN and/or WiFi networks (i.e., no non-local traffic captures). </p> <p> Now disconnect the machine from the network. That will prevent pings from completing. In Windows, you will see "Request timed out." In IOS and Linux, ping output will just stop. Then reconnect the machine to the network. If all goes well, ping replies should start appearing again. Refresh the IP-check site in your browser. You should still see your VPN exit address. In the traffic capture window, you should still see no non-local captures. In Windows, you may see lots of local traffic. To check more thoroughly, you can view tcpdump.log in a test editor. </p> <h2> Failure Modes and Options </h2> <p> Failure shows up in a few main ways. Most blatantly, the openvpn process (not just the VPN connection) may die after loss of network connectivity. So after network connectivity is restored, the IP-check site will report your ISP-assigned IP address. And you will see numerous non-local traffic captures. Network Manager in Linux is prone to this failure mode, by the way, and should be avoided. </p> <p> Less blatantly, but more insidiously, the VPN client may reconnect after network connectivity is restored, and the IP-check site will still report your VPN exit IP address. You might not notice any interruption. But you will see non-local traffic captures, generated by pings that succeeded before the VPN tunnel came back up. Just one leaked packet is enough to reveal your ISP-assigned IP address. </p> <p> Plain vanilla OpenVPN tends to fail in a way that's somewhat easier to manage, but still dangerous. If a network interruption lasts long enough to kill the VPN connection, OpenVPN can't reestablish the connection. As long as OpenVPN is running, all traffic is routed through the VPN gateway, which is dead. And so there's no network connectivity. Pings will fail, and you will see no traffic captures. Default routing isn't restored until the openvpn process is killed. So one could close apps accessing sensitive network resources, kill the openvpn process, and then reconnect the VPN. Or one could just reboot. But those are tedious hacks, and prone to error. </p> <p> You can use the same approach to see how your VPN client responds to other perturbations. Sleep and resume. Change WiFi access points. Use a network with full IPv6 connectivity. Whatever. Inspection of tcpdump.log and ping.log should reveal any leaks. </p> <p> If you find that your VPN client leaks, one option is to try another VPN provider, and test their client. I haven't managed to make iVPN's Windows and IOS clients leak. But iVPN doesn't have a Linux client. However, blocking leaks in Linux is easy with <a href="https://github.com/adrelanos/VPN-Firewall">adrelanos' vpn-firewall</a>. I recommend using it with the built-in openvpn service, not Network Manager. Basically, it allows all apps to use the VPN tunnel, and blocks everything on the physical interface except for connections to the VPN server. You can use the same firewall logic in Windows and OSX. In Windows, you can just use Windows Firewall. In OSX, you can use <a href="http://www.hanynet.com/icefloor/">IceFloor</a>, which is a GUI front end for OpenBSD's PF firewall. </p> <h2> Other Kinds of Leaks </h2> <p> Even if all traffic is being routed through your VPN, it's possible that <a href="https://en.wikipedia.org/wiki/Domain_Name_System">DNS requests</a> are going to a DNS server that's operated by, or associated with, your ISP. Even though your requests are coming from the VPN exit, an adversary observing both the DNS server and your ISP traffic could correlate activity. If the VPN server uses the same IP address for access and exit, correlation becomes trivial. Now the adversary knows what sites you are accessing. </p> <p> The HTML5 Geolocation API enables a potentially serious leak. It caches and reports available location data. Perhaps you've provided your location, in order to get local weather information. If you use WiFi, your location can be triangulated from accessible access points. If you're using a smartphone, the ID of the base station locates you approximately. And maybe you have GPS turned on. But there's no problem as long as only IP address information is available. The simplest option is to disable geolocation, as explained at <a href="http://www.baatkar.com/2015/04/how-to-fake-your-location-in-google.html">Digital Adda</a>. </p> <p> WebRTC is another indiscreet HTML5 feature. If enabled in the browser, it reports local IP address. And if IPv6 is functional, it reports local IPv6 address, which is typically device-specific. So it's prudent to prevent WebRTC leaks by installing the "WebRTC Control" browser addon. Also, as noted above, it's prudent to disable IPv6 in the OS, and to block all IPv6 traffic in the firewall. </p> <p> Sites that you visit can also estimate the number of intervening routers by inspecting received SYN packets. The default initial time to live (TTL) for SYN packets varies by OS. The browser User-Agent string identifies the OS. And the TTL value is decreased each time the packet passes through a router. The difference between expected and observed TTL provides an estimate for the number of intervening routers. </p> <p> If you intend to test for leaks using other third-party sites, I recommend using Tor browser, because it's been hardened to block WebGL fingerprinting, and otherwise to report the same fingerprints for all users. But you obviously don't want to use Tor while testing your VPN. First, download <a href="https://www.torproject.org/download/download">Tor browser</a> for your OS. Do that with your VPN connected, so your ISP doesn't see. After extracting, start Tor browser. You can probably accept all defaults. Go to advanced network settings, and select "No proxy". Browse about:config, and toggle both "extensions.torlauncher.start<em>tor" and "network.proxy.socks</em>remote_dns" to "false". Then browse <a href="https://check.torproject.org/">check.torproject.org</a>. You should see "Sorry. You are not using Tor." and your VPN exit IP address. </p> <p> It's true that you can't investigate WebGL and other fingerprinting using Tor browser. If you choose to test using other browsers, you should be very careful. As noted above, all WebGL-capable browsers on a given system will have the same WebGL fingerprint. So you should avoid using the same system with and without a VPN connected. You should also avoid using different VPN services, unless you don't care that the system will be associated with both. Furthermore, if you use VMs, you should not use related operating systems with and without a VPN, or with different VPN services. </p> <h2> Summary </h2> <p> Bottom line, here are the key tests, and the results that you should get: </p> <ul> <li> <a href="http://ipv6.whatismyv6.com/">IPv6 address test</a>: browser unable to connect </li> <li> <a href="https://www.browserleaks.com/whois">IP address test</a>: expected IP addresses with and without VPN connected </li> <li> <a href="https://www.browserleaks.com/geo">geolocation test</a>: browser doesn't support geolocation API </li> <li> <a href="https://www.browserleaks.com/java">Java test</a>: not found, or disabled </li> <li> <a href="https://www.browserleaks.com/webgl">WebGL test</a>: WebGL blocked by NoScript </li> <li> <a href="https://www.browserleaks.com/webrtc">WebRTC test</a>: not enabled </li> <li> <a href="https://panopticlick.eff.org/">Panopticlick</a>: browser protects from fingerprinting </li> <li> <a href="https://dnsleaktest.com/">DNS Leak Test (use extended test)</a>: different DNS server(s) with and without VPN connected </li> </ul>