Skip to content

Commit

Permalink
partial fix for DNS leaks in VPN lockdown mode
Browse files Browse the repository at this point in the history
For now, we need to omit the case where the VPN DNS is being used to
avoid compatibility issues.
  • Loading branch information
thestinger committed Aug 4, 2024
1 parent 2e032e8 commit 91caf5c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions server/NetworkController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ uint32_t NetworkController::getNetworkForDnsLocked(unsigned* netId, uid_t uid) c
*netId = defaultNetId;
fwmark.netId = *netId;
fwmark.explicitlySelected = true;
fwmark.protectedFromVpn = canProtectLocked(uid);
fwmark.permission = getPermissionForUserLocked(uid);
return fwmark.intValue;
}

Expand All @@ -240,6 +242,11 @@ uint32_t NetworkController::getNetworkForDnsLocked(unsigned* netId, uid_t uid) c
if (network && network->isVirtual() && !resolv_has_nameservers(*netId)) {
*netId = defaultNetId;
}

if (!network || !network->isVirtual() || !resolv_has_nameservers(*netId)) {
fwmark.protectedFromVpn = canProtectLocked(uid);
fwmark.permission = getPermissionForUserLocked(uid);
}
} else {
// If the user is subject to a VPN and the VPN provides DNS servers, use those servers
// (possibly falling through to the default network if the VPN doesn't provide a route to
Expand All @@ -252,6 +259,8 @@ uint32_t NetworkController::getNetworkForDnsLocked(unsigned* netId, uid_t uid) c
// TODO: return an error instead of silently doing the DNS lookup on the wrong network.
// http://b/27560555
*netId = defaultNetId;
fwmark.protectedFromVpn = canProtectLocked(uid);
fwmark.permission = getPermissionForUserLocked(uid);
}
}
fwmark.netId = *netId;
Expand Down

0 comments on commit 91caf5c

Please sign in to comment.