Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore the DNS over HTTPS work-around on Windows #15989

Merged
merged 1 commit into from
Dec 13, 2022

Conversation

spylogsster
Copy link
Contributor

@spylogsster spylogsster commented Nov 17, 2022

Re-introduces logic from #13434 This reverts commit b9f88f6.

Fixes brave/brave-browser#26787

  • If the setting is disabled by policy or parental control it will not be overriden and we show a separate notification about this.
  • In all other cases settings () are locked when vpn is enabled

Example of notification message for warning about overriding the setting
image

DnsOverHttpsMode is off by policy we show warning message because user has DNS leak. Pref to skip warning message is saved to the profile prefs
image

without policy we override user's settings to Cloudflare DoH automatically and block settings form changing:
image

Submitter Checklist:

  • I confirm that no security/privacy review is needed, or that I have requested one
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally: npm run test -- brave_browser_tests, npm run test -- brave_unit_tests, npm run lint, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

For official test plan, see brave/brave-browser#26787

  • See detailed logic section in the description

@spylogsster spylogsster self-assigned this Nov 17, 2022
@spylogsster spylogsster force-pushed the bsc-restore-windows-doh-workaround branch 3 times, most recently from 505ccde to 6336008 Compare November 17, 2022 11:22
@spylogsster spylogsster changed the title wip: Restore the DNS over HTTPS work-around on Windows Restore the DNS over HTTPS work-around on Windows Nov 17, 2022
@spylogsster spylogsster marked this pull request as ready for review November 17, 2022 11:23
@spylogsster spylogsster force-pushed the bsc-restore-windows-doh-workaround branch from 6336008 to 91ad8e1 Compare November 17, 2022 11:36
@spylogsster spylogsster requested a review from a team as a code owner November 18, 2022 13:06
@spylogsster spylogsster force-pushed the bsc-restore-windows-doh-workaround branch 19 times, most recently from f3efb3d to fe1db43 Compare November 22, 2022 13:10
@@ -22,18 +22,16 @@
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "net/base/network_change_notifier.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was this header added?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

old code used it, removed in c2b3991

@@ -9,6 +9,7 @@
#include <string>

#include "build/build_config.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above, but also there's not need to duplicate the same header in .h and .cc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above, removed in c2b3991

@@ -12,6 +12,7 @@ namespace brave_vpn {
namespace features {

BASE_DECLARE_FEATURE(kBraveVPN);
BASE_DECLARE_FEATURE(kBraveVPNDnsProtection);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_win buildflag

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added in 08d26ca

@@ -3,7 +3,41 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "brave/components/brave_vpn/buildflags/buildflags.h"
#include "build/build_config.h"
#include "build/buildflag.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was this added?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

obsolete, removed in 08d26ca

bool skip_notification_dialog_for_testing_ = false;
raw_ptr<PrefService> local_state_;
raw_ptr<PrefService> profile_prefs_;
raw_ptr<PrefService> pref_service_for_testing_;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is unnecessary, you can control the pref service by either passing it in directly or with TestingProfile::Builder::SetPrefService, but it also doesn't appear to be used anywhere. It's also ambiguous in terms of profile vs local

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

obsolete, removed in 08d26ca

void BraveSecureDnsHandler::OnJavascriptAllowed() {
SecureDnsHandler::OnJavascriptAllowed();
pref_registrar_.Init(g_browser_process->local_state());
#if BUILDFLAG(IS_WIN)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in a follow-up we should rename these files with _win

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spylogsster spylogsster force-pushed the bsc-restore-windows-doh-workaround branch from 8086276 to f460f6b Compare December 12, 2022 16:50

#include "base/feature_list.h"
#include "brave/components/brave_vpn/features.h"
#include "chrome/browser/browser_process.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused header

Copy link
Contributor Author

@spylogsster spylogsster Dec 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is used by pref registrar

@@ -24,11 +24,9 @@ void MigrateVPNSettings(PrefService* profile_prefs, PrefService* local_prefs);
void RegisterLocalStatePrefs(PrefRegistrySimple* registry);
void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
void RegisterAndroidProfilePrefs(PrefRegistrySimple* registry);

#if !BUILDFLAG(IS_ANDROID)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there are no other changes to this file then please set it back to the original state to reduce the diff

Copy link
Contributor Author

@spylogsster spylogsster Dec 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in beb1228

"brave.brave_vpn.show_dns_policy_warning_dialog";
#endif // BUILDFLAG(IS_WIN)
constexpr char kBraveVPNShowNotificationDialog[] =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one also belongs in IS_WIN

Copy link
Contributor Author

@spylogsster spylogsster Dec 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in beb1228

@spylogsster spylogsster force-pushed the bsc-restore-windows-doh-workaround branch 5 times, most recently from beb1228 to 714ee86 Compare December 13, 2022 08:56
@spylogsster spylogsster force-pushed the bsc-restore-windows-doh-workaround branch from 714ee86 to 808fd9a Compare December 13, 2022 12:19
@brave brave deleted a comment from github-actions bot Dec 13, 2022
@spylogsster spylogsster force-pushed the bsc-restore-windows-doh-workaround branch from 808fd9a to 85c07e3 Compare December 13, 2022 13:55
@spylogsster spylogsster merged commit 604800b into master Dec 13, 2022
@spylogsster spylogsster deleted the bsc-restore-windows-doh-workaround branch December 13, 2022 15:14
@github-actions github-actions bot added this to the 1.48.x - Nightly milestone Dec 13, 2022
@spylogsster spylogsster restored the bsc-restore-windows-doh-workaround branch December 13, 2022 15:17
spylogsster added a commit that referenced this pull request Dec 13, 2022
Re-introduces logic from #13434
This reverts commit b9f88f6.

Fixes brave/brave-browser#26787

Co-authored-by: Brian Clifton <brian@clifton.me>
@bsclifton bsclifton deleted the bsc-restore-windows-doh-workaround branch December 13, 2022 18:27
@stephendonner
Copy link
Contributor

stephendonner commented Dec 14, 2022

Verification PASSED using

Brave 1.48.52 Chromium: 108.0.5359.99 (Official Build) nightly (64-bit)
Revision 410951fc34bb4b2cbf182231f9f779efaafaf682-refs/branch-heads/5359_71@{#9}
OS Windows 10 Version 22H2 (Build 19045.2364)

"Happiest of paths" - PASSED

  1. installed 1.48.52
  2. launched Brave
  3. opened brave://flags
  4. set brave://flags/#brave-vpn to Enabled
  5. clicked Relaunch
  6. loaded account.bravesoftware.com
  7. entered basic-auth credentials
  8. entered dec1405@mailinator.com and clicked Get login link
  9. clicked Log in to Brave from the resulting email
  10. clicked on Browse plans
  11. scrolled down to Brave VPN Subscription and clicked Buy now
  12. filled out Stripe and clicked Subscribe
  13. connected to BraveVPN
  14. confirmed I got the DoH warning modal
  15. clicked OK
  16. loaded https://browserleaks.com/dns
  17. confirmed my local ISP (AT&T) DNS resolvers aren't shown
  18. confirmed Cloudflare resolvers are shown
step 14 steps 16-18
image image

Confirmed only Cloudflare DNS resolvers were shown, not my local A&T (ISP) ones

Ensure Do not warn me about this anymore works - PASSED

Pre-requisite: ran Happiest of paths test

  1. continued from Happiest of paths test
  2. clicked on Do not warn me about this anymore
  3. disconnected from BraveVPN via the macOS Network panel
  4. reconnected to BraveVPN via the browser's VPN button toggle
  5. confirm the modal doesn't show again

Confirmed no more DoH warning modal(s)

step 2 step 3 steps 4-5
image image image

Confirmed I was not presented with the Do not warm me about this anymore DoH leak-warning dialog

User enables DoH and connects to VPN - PASSED

  1. fresh profile
  2. open brave://settings/security and under Use secure DNS pick With Cloudflare (1.1.1.1)
  3. purchased, enabled, and connected to BraveVPN (see steps above)
  4. confirmed no DoH warning modal
  5. reloaded brave://settings/security
  6. confirmed my DoH settings were not overwritten
  7. changed to Cloudflare
  8. changed settings for Use secure DNS to With your current service provider
  9. connected to BraveVPN
  10. confirmed I got the DoH warning modal

Confirmed whenever I connected to BraveVPN, Use secure DNS was automatically collapsed and enabled, and I got the DoH DNS-leak warning dialog

step 3 step 4 steps 5-6 step 9-10
image image image image

Group policy - PASSED

When DnsOverHttpsMode is overriden - PASSED

  1. opened regedit.exe
  2. elevated user permissions
  3. navigated to HKEY_LOCAL_MACHINE\SOFTWARE\Policies\
  4. context-clicked the Brave branch in the registry tree, and chose New -> string
  5. entered DnsOverHttpsMode
  6. set its value to off
  7. opened brave://settings/security and confirmed the Use secure DNS setting should not be editable (shows a "house" icon - managed via policy)
  8. ran through Happiest of Paths test
  9. confirmed the Secure DNS is disabled by your... warning dialog text
  10. clicked on OK to dismiss

Confirmed while connected to BraveVPN with the above policy, I saw both the DoH warning dialog, as well as the tooltip + home icon, in the Settings panel

steps 1-6 step 7 step 9 step 10
image image image image

When DnsOverHttpsMode and DnsOverHttpsTemplates are overriden - PASSED

  1. set the value of DnsOverHttpsMode to secure (from off)
  2. create a string key of DnsOverHttpsTemplates and set its value to https://chrome.cloudflare-dns.com/dns-query
  3. open brave://settings/security and confirmed the Use secure DNS setting is disabled (with the house icon)
  4. run the Happiest of paths test
  5. confirm no DoH warning dialogs when successfully reconnecting to BraveVPN
step 2 step 3 step 5
image image image

Security and Privacy - PASSED

DNS-over-HTTPs (DOH) - PASSED

  1. connect to BraveVPN
  2. click OK on the DoH DNS leak warning dialog
  3. load browserleaks.com/dns
  4. confirm you see only Cloudflare DNS-server IPs
DoH warning dialog browserleaks.com/dns
image image

DNS leak (ISP) - PASSED

  1. connect to BraveVPN
  2. load https://browserleaks.com/dns
  3. confirm local ISP (AT&T) DNS resolvers aren't shown (they should be from the connected region, Cloudflare)
  4. disconnect from BraveVPN
  5. reload https://browserleaks.com/dns
  6. confirm local ISP (AT&T) DNS resolvers are shown
step 3 step 4 step 5-6
image image image

Tor - PASSED

  1. connect to BraveVPN
  2. open a New Private window with Tor
  3. load check.torproject.org
  4. ensure you see Congratulations. This browser is configured to use Tor.

image

Torrent (via WebTorrents support) - PASSED

  1. disconnect from a working BraveVPN setup
  2. load https://ipleak.net
  3. click on Activate under Torrent Address detection
  4. click on this Magnet Link (it'll open in a new window)
  5. reload the URL
  6. click on Start Torrent
  7. return to the https://ipleak.net tab
  8. confirm that you see your public (local ISP) IP address
  9. connect to BraveVPN
  10. click OK on the DoH leak warning dialog
  11. shift + reload the page (to clear cache)
  12. repeat steps 3-7
  13. confirm you now see the appropriate VPN IP address (for the connected region)
  14. switch to another region (for bonus points!)

Actual torrenting looks to be blocked on BraveVPN, with the recent change to DoH mitigation:

beta - works nightly - fails
image image

Will investigate the above further, but it shouldn't block the DoH-mitigation code here from moving forward 👍

step 4 step step step step
image image image image image

WebRTC - PASSED

  1. connect to BraveVPN
  2. open brave://settings/privacy
  3. load https://browserleaks.com/webrtc in a new tab
  4. iterate through the values for WebRTC IP handling policy
  5. note the absence/presence and value of both local + public IP addresses, as reflected by their respective setting

VPN connected

Default Default public and private interfaces Default public interface only Disable non-proxied UDP
image image image image

Disconnected from VPN

Default Default public and private interfaces Default public interface only Disable non-proxied UDP
image image image image

kjozwiak added a commit that referenced this pull request Dec 15, 2022
(Uplift 1.47.x)  Restore the DNS over HTTPS work-around on Windows (#15989)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Windows 10 leaks DNS when using VPN by sending DNS to all network interfaces
5 participants