From: Tobias Brunner Date: Fri, 21 Sep 2018 13:07:44 +0000 (+0200) Subject: android: Avoid DNS leak due to blocking TUN device without DNS servers X-Git-Tag: 5.7.2dr1~15 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=84ee9577e1c7d68e149310ca0f1d2e6cec9cfdab;p=thirdparty%2Fstrongswan.git android: Avoid DNS leak due to blocking TUN device without DNS servers It looks like Android 9 incorrectly continues to use the regular DNS servers after the blocking TUN device is replaced with the actual interface. Setting DNS servers prevents that (since all traffic is blocked, which ones doesn't really matter but local/loopback addresses are rejected). Interestingly, if the VPN server later does not assign any DNS servers, there is no fallback to the non-VPN DNS servers for some reason (that's definitely not as documented). This could potentially be a problem as we don't offer an option to configure DNS servers in the VPN profile. Neither issue is seen on older Android versions (only tested on 7.1.1). --- diff --git a/src/frontends/android/app/src/main/java/org/strongswan/android/logic/CharonVpnService.java b/src/frontends/android/app/src/main/java/org/strongswan/android/logic/CharonVpnService.java index 2777202b59..ac9ff495fa 100644 --- a/src/frontends/android/app/src/main/java/org/strongswan/android/logic/CharonVpnService.java +++ b/src/frontends/android/app/src/main/java/org/strongswan/android/logic/CharonVpnService.java @@ -930,6 +930,9 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe mCache.addAddress("fd00::fd02:1", 128); mCache.addRoute("0.0.0.0", 0); mCache.addRoute("::", 0); + /* set DNS servers to avoid DNS leak later */ + mBuilder.addDnsServer("8.8.8.8"); + mBuilder.addDnsServer("2001:4860:4860::8888"); /* use blocking mode to simplify packet dropping */ mBuilder.setBlocking(true); ParcelFileDescriptor fd = establishIntern();