brave / brave-browser

Brave browser for Android, iOS, Linux, macOS, Windows.
https://brave.com
Mozilla Public License 2.0
17.84k stars 2.33k forks source link

Implement OpenVPN style DNS resolving #25489

Closed bsclifton closed 1 year ago

bsclifton commented 2 years ago

Description

Basically, Windows can leak your ISP due to Smart Multi-Homed Name Resolution (even when you're on VPN). This is a feature of Windows and is expected behavior. See https://github.com/brave/brave-browser/issues/22163 for full details.

We had attempted a solution using DNS over HTTP (see https://github.com/brave/brave-core/pull/13434) but there were a few issues. See https://github.com/brave/brave-browser/issues/25488 where we want to back this pull request and logic out.

The example shared by @bridiver can be found here: https://github.com/OpenVPN/openvpn/blob/d92075e0ae6dba84a2e30e4ec12ca29250945371/src/openvpn/block_dns.c

This will block the other adapters (that Smart Multi-Homed Name Resolution would dispatch to) while Brave is open - meaning it will apply to all programs running on the device (instead of only queries made within Brave). A good test would be to hit https://browserleaks.com/dns from another browser when connected using the OpenVPN work-around

More context and details available to Brave employees by reading the security re-review here: https://github.com/brave/security/issues/1029

Test cases

Start Brave, check browserleaks.com/dns shows your real location in any browser

Start Brave, check browserleaks.com/dns shows your real location in any browser

Install Brave without admin permissions,

Install Brave as admin

Install Brave as admin

IPv6 test: VPN OFF

bsclifton commented 2 years ago

Needs discussion; marking as blocked for now

This is not a blocker for the release though

stephendonner commented 1 year ago

Removing blocked label as it's implemented, with QA/Yes and a provided testplan.

stephendonner commented 1 year ago

Verification PASSED using

Brave 1.50.91 Chromium: 111.0.5563.64 (Official Build) beta (64-bit)
Revision c710e93d5b63b7095afe8c2c17df34408078439d-refs/branch-heads/5563@{#995}
OS Windows 10 Version 22H2 (Build 19045.2728)

Admin-installed Brave - PASSED

Brave VPN Helper-service dynamic launching - PASSED

Steps: 1. (with Brave VPN installed as Admin, and configured) 2. launch Brave 3. click on the `VPN` button 4. toggle VPN to `Connected` 5. press `ctrl` + `alt` + `del` 6. click on `Task Manager` 7. confirm the presence of `Brave VPN Helper` service processes 8. disconnect and reconnect `Brave VPN` 9. confirm you see the processes disappear and then re-appear `Brave VPN` `ON` | `Brave VPN` `OFF`| `Brave VPN` `ON` ----------|-----------|--------- ![image](https://user-images.githubusercontent.com/387249/225522874-b9129825-02e8-47c9-9dae-9ccfb3de398f.png) | ![image](https://user-images.githubusercontent.com/387249/225523616-f32df3fe-fbf5-458b-ae8f-448fc132b706.png) | ![image](https://user-images.githubusercontent.com/387249/225523966-574a2075-ecc2-45d7-ab2e-1fb0b5126c87.png)

Brave VPN Helper-service process kill & respawn - PASSED

Steps: 1. (with Brave VPN installed as Admin, and configured) 2. launch Brave 3. connect to `BraveVPN` 4. open the `Task Manager` via `ctrl` + `alt` + `del` 5. look for the `Brave Beta Vpn Service` process 6. kill the helper service executable by clicking `End task` in `Task Manager` 7. confirm the service automatically restarts after crash 8. repeat a few times to kill it again and check the service will be restarted 3 times in total 9. after killing the service the 4th time, it should not be restarted again 10. disconnect/Connect VPN again from Brave Browser and check it uses overridden DoH instead of VPN service. DNS leak should not happen. `screencast` | `browserleaks.com/dns` | `brave://settings/security` ------------|--------------------------|----------------------------- ![brave-vpn-helper](https://user-images.githubusercontent.com/387249/226074350-fc4180cd-76bc-4d68-8501-baadf48fc347.gif) | ![image](https://user-images.githubusercontent.com/387249/226074593-f83425e3-87dc-4c5f-ae0d-dd8f8f169d50.png) | ![image](https://user-images.githubusercontent.com/387249/226074547-77886c50-1300-4b14-aa32-5f2f9de5a323.png)

Crash reporting - PASSED

Steps: 1. (with Brave VPN installed as Admin, and configured) 2. open `Registry Editor` 3. look for `Computer\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\BraveBetaVpnService` 4. edit the `ImagePath` string to be `"C:\Program Files\BraveSoftware\Brave-Browser-Beta\Application\111.1.50.94\brave_vpn_helper.exe" --crash-me` (or similar) 5. launch Brave 6. connect to `Brave VPN` 7. press `ctrl` + `alt` + `del` to open `Task Manager` 8. context click on one of the column headings 9. toggle `Command line` on 10. look for the `brave_vpn_helper.exe` process that's launched with `--type=crashpad-handler` 11. toggle `Brave VPN` to `Disconnected` 12. toggle `Brave VPN` to `Connected` 13. confirm the `brave_vpn_helper.exe` process disappears from the `Task Manager` (as it crashed) 14. open `C:\ProgramData\BraveSoftware\BraveBetaVpnService\Crashpad\reports` 15. confirm crash-report .dmp (dump) files populate the above folder for each crash 16. grab a `.dmp` filename 17. load `https://brave.sp.backtrace.io/` 18. enter basic auth 19. set the filters to `upload_file_minidump` `equal_to` `dump-filename` (without the `.dmp` extension) 20. press `enter` 21. confirm crash-dump report loads example | example | example | example ---------|----------|---------|--------- ![image (2)](https://user-images.githubusercontent.com/387249/226409812-62fc971b-78de-4bda-aa6c-19d39b695ba3.png) | ![image](https://user-images.githubusercontent.com/387249/226407164-e3e9a70b-5ae6-4781-98b2-8b1603bca8e4.png) | ![crash-handler](https://user-images.githubusercontent.com/387249/226409399-d1bac793-5de7-4780-bcfa-3ef5b498fb45.gif) | Screen Shot 2023-03-20 at 9 27 54 AM

Non-admin installed Brave

DoH fallback - PASSED

1. double-click on the appropriate `beta` build's ` installer 2. when prompted by Windows to allow the app to make changes, click `No` 3. click `Yes` on the `Brave-Browser-Beta can be installed without administrator privileges. Continue?` dialog 4. configure `Brave VPN` 5. launch Brave 6. connect to `Brave VPN` 7. press `ctrl` + `alt` + `del` to open `Task Manager` 8. ensure there's no `Brave VPN Helper` service/process running 9. load `https://browserleaks.com/dns` 10. confirm under `ISP` your local ISP's DNS resolvers aren't shown (should be Cloudflare) 11. open `brave://settings/security` 12. confirm it says `This setting is locked by BraveVPN while it is connected`, under `Use Secure DNS` `Task Manager`| `browserleaks.com/dns` | `brave://settings/security` ----------|----------|------------- ![image](https://user-images.githubusercontent.com/387249/225541130-72b6834d-9fa8-4e34-a231-c22a23a671f2.png) | ![image](https://user-images.githubusercontent.com/387249/225541392-bd83d90b-a578-427b-88ce-b2eb3c0d7228.png) | ![image](https://user-images.githubusercontent.com/387249/225541865-51d48bb2-e567-46be-94f7-970e989ccedc.png)

IPv6 Connectivity- PASSED

test-ipv6.com - PASSED Steps: 1. (with Brave VPN installed as Admin, and configured) 2. launch Brave 3. connect to `Brave VPN` 4. load `https://test-ipv6.com` 5. confirm you receive a score, in red, of `0/10` 6. disconnect from `Brave VPN` 7. reload the URL 8. confirm you receive a score, in green, of `10/10` `VPN off` | `VPN on` ---------|---------- ![image (2)](https://user-images.githubusercontent.com/387249/225456911-9b95c135-2b87-44d0-b77b-c27de9e75719.png) | ![image (1)](https://user-images.githubusercontent.com/387249/225456786-cb34d8dc-29f5-4193-bc43-2fd7440e5cf8.png)
ipv6-test.com - PASSED Steps: 1. (with Brave VPN installed as Admin, and configured) 2. launch Brave 3. connect to `Brave VPN` 4. load `https://ipv6-test.com` 5. confirm `IPv6` reads `Not supported` under `IPv6 connectivity` 6. disconnect from `Brave VPN` 7. reload `https://ipv6-test.com` 8. confirm `IPv6` reads `Supported` `VPN off` | `VPN on` ---------|--------- ![image](https://user-images.githubusercontent.com/387249/225519743-fd24c8a4-20b9-4b3f-bef3-a67d73971fc9.png) | ![image](https://user-images.githubusercontent.com/387249/225519870-2dd69bfd-acf3-4a38-a1b3-019cc2653233.png)
IPv6 address reachability (ping) - PASSED Steps: 1. (with Brave VPN installed as Admin, and configured) 2. launch Brave 3. with `Brave VPN` `Disconnected`, ping `2001:470:1:18::223:250` 4. confirm it responds to all pings, with 0% packet loss 5. connect to `BraveVPN` 6. ping `2001:470:1:18::223:250` 7. confirm it drops all packets, with 100% loss `VPN off` | `VPN on` ---------|-------- ![image](https://user-images.githubusercontent.com/387249/225458649-a65a6c8b-ace2-4ffe-8117-5de9235e83cd.png) | ![image](https://user-images.githubusercontent.com/387249/225458748-84d7b8ba-6415-4827-bed4-fb46388fca27.png)
spylogsster commented 1 year ago

one more PR for crashes autoupload https://github.com/brave/brave-core/pull/17074

stephendonner commented 1 year ago

Verification IN-PROGRESS using

Brave 1.50.93 Chromium: 111.0.5563.64 (Official Build) beta (64-bit)
Revision c710e93d5b63b7095afe8c2c17df34408078439d-refs/branch-heads/5563@{#995}
OS Windows 11 Version 21H2 (Build 22000.1641)

Admin-installed Brave - PENDING

Brave VPN Helper-service dynamic launching - PENDING

Steps: 1. (with Brave VPN installed as Admin, and configured) 2. launch Brave 3. click on the `VPN` button 4. toggle VPN to `Connected` 5. press `ctrl` + `alt` + `del` 6. click on `Task Manager` 7. confirm the presence of `Brave VPN Helper` service processes 8. disconnect and reconnect `Brave VPN` 9. confirm you see the processes disappear and then re-appear `Brave VPN` `ON` | `Brave VPN` `OFF`| `Brave VPN` `ON` ----------|-----------|--------- image|image|image

Brave VPN Helper-service process kill & respawn - PENDING

Steps: 1. (with Brave VPN installed as Admin, and configured) 2. launch Brave 3. connect to `BraveVPN` 4. open the `Task Manager` via `ctrl` + `alt` + `del` 5. look for the `Brave Beta Vpn Service` process 6. kill the helper service executable by clicking `End task` in `Task Manager` 7. confirm the service automatically restarts after crash 8. repeat a few times to kill it again and check the service will be restarted 3 times in total 9. after killing the service the 4th time, it should not be restarted again 10. disconnect/Connect VPN again from Brave Browser and check it uses overridden DoH instead of VPN service. DNS leak should not happen. `screencast` | `browserleaks.com/dns` | `brave://settings/security` ------------|--------------------------|-----------------------------

Crash reporting - PENDING

Steps: 1. (with Brave VPN installed as Admin, and configured) 2. open `Registry Editor` 3. look for `Computer\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\BraveBetaVpnService` 4. edit the `ImagePath` string to be `"C:\Program Files\BraveSoftware\Brave-Browser-Beta\Application\111.1.50.94\brave_vpn_helper.exe" --crash-me` (or similar) 5. launch Brave 6. connect to `Brave VPN` 7. press `ctrl` + `alt` + `del` to open `Task Manager` 8. context click on one of the column headings 9. toggle `Command line` on 10. look for the `brave_vpn_helper.exe` process that's launched with `--type=crashpad-handler` 11. toggle `Brave VPN` to `Disconnected` 12. toggle `Brave VPN` to `Connected` 13. confirm the `brave_vpn_helper.exe` process disappears from the `Task Manager` (as it crashed) 14. open `C:\ProgramData\BraveSoftware\BraveBetaVpnService\Crashpad\reports` 15. confirm crash-report .dmp (dump) files populate the above folder for each crash 16. grab a `.dmp` filename 17. load `https://brave.sp.backtrace.io/` 18. enter basic auth 19. set the filters to `upload_file_minidump` `equal_to` `dump-filename` (without the `.dmp` extension) 20. press `enter` 21. confirm crash-dump report loads example | example | example | example ---------|----------|---------|---------

Non-admin installed Brave

DoH fallback - PENDING

1. double-click on the appropriate `beta` build's ` installer 2. when prompted by Windows to allow the app to make changes, click `No` 3. click `Yes` on the `Brave-Browser-Beta can be installed without administrator privileges. Continue?` dialog 4. configure `Brave VPN` 5. launch Brave 6. connect to `Brave VPN` 7. press `ctrl` + `alt` + `del` to open `Task Manager` 8. ensure there's no `Brave VPN Helper` service/process running 9. load `https://browserleaks.com/dns` 10. confirm under `ISP` your local ISP's DNS resolvers aren't shown (should be Cloudflare) 11. open `brave://settings/security` 12. confirm it says `This setting is locked by BraveVPN while it is connected`, under `Use Secure DNS` `Task Manager`| `browserleaks.com/dns` | `brave://settings/security` ----------|----------|-------------

IPv6 Connectivity- PENDING

test-ipv6.com - PENDING Steps: 1. (with Brave VPN installed as Admin, and configured) 2. launch Brave 3. connect to `Brave VPN` 4. load `https://test-ipv6.com` 5. confirm you receive a score, in red, of `0/10` 6. disconnect from `Brave VPN` 7. reload the URL 8. confirm you receive a score, in green, of `10/10` `VPN off` | `VPN on` ---------|----------
ipv6-test.com - PENDING Steps: 1. (with Brave VPN installed as Admin, and configured) 2. launch Brave 3. connect to `Brave VPN` 4. load `https://ipv6-test.com` 5. confirm `IPv6` reads `Not supported` under `IPv6 connectivity` 6. disconnect from `Brave VPN` 7. reload `https://ipv6-test.com` 8. confirm `IPv6` reads `Supported` `VPN off` | `VPN on` ---------|---------
IPv6 address reachability (ping) - PENDING Steps: 1. (with Brave VPN installed as Admin, and configured) 2. launch Brave 3. with `Brave VPN` `Disconnected`, ping `2001:470:1:18::223:250` 4. confirm it responds to all pings, with 0% packet loss 5. connect to `BraveVPN` 6. ping `2001:470:1:18::223:250` 7. confirm it drops all packets, with 100% loss `VPN off` | `VPN on` ---------|--------
stephendonner commented 1 year ago

Removing QA Pass-Win64 as this also needs to be verified on Windows 11.

stephendonner commented 1 year ago

Removing QA Pass-Win64 as this also needs to be verified on Windows 11.

Something's wrong with my installation/setup on Windows 11, so I logged https://github.com/brave/brave-browser/issues/29217.

stephendonner commented 1 year ago

@MadhaviSeelam do you have bandwidth to take this, since my personal Windows 11 installation is neither true release (it's a preview release) nor acting right, per the above issue? Thanks!

MadhaviSeelam commented 1 year ago

Verification PASSED using

Brave | 1.50.110 Chromium: 112.0.5615.49 (Official Build) (64-bit)
-- | --
Revision | bd2a7bcb881c11e8cfe3078709382934e3916914-refs/branch-heads/5615@{#936}
OS | Windows 11 Version 22H2 (Build 22621.1413)

Admin-installed Brave - PASSED

Brave VPN Helper-service dynamic launching - PASSED

Steps: 1. (with Brave VPN installed as Admin, and configured) 2. launch Brave 3. click on the `VPN` button 4. toggle VPN to `Connected` 5. press `ctrl` + `alt` + `del` 6. click on `Task Manager` 7. confirm the presence of `Brave VPN Helper` service processes 8. disconnect and reconnect `Brave VPN` 9. confirm you see the processes disappear and then re-appear `Brave VPN` `ON` | `Brave VPN` `OFF`| `Brave VPN` `ON` ----------|-----------|--------- image|image|image

Brave VPN Helper-service process kill & respawn - PASSED

Steps: 1. (with Brave VPN installed as Admin, and configured) 2. launch Brave 3. connect to `BraveVPN` 4. open the `Task Manager` via `ctrl` + `alt` + `del` 5. look for the `Brave Beta Vpn Service` process 6. kill the helper service executable by clicking `End task` in `Task Manager` 7. confirm the service automatically restarts after crash 8. repeat a few times to kill it again and check the service will be restarted 3 times in total 9. after killing the service the 4th time, it should not be restarted again 10. disconnect/Connect VPN again from Brave Browser and check it uses overridden DoH instead of VPN service. DNS leak should not happen. `screencast` https://user-images.githubusercontent.com/98358127/230138286-51fe834e-2cf1-4e26-b173-dbe1dda14d03.mp4 `browserleaks.com/dns` | `brave://settings/security` ------------|-------------------------- image|image

Crash reporting - PASSED

Steps: 1. (with Brave VPN installed as Admin, and configured) 2. open `Registry Editor` 3. look for `Computer\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\BraveBetaVpnService` 4. edit the `ImagePath` string to be `"C:\Program Files\BraveSoftware\Brave-Browser-Beta\Application\111.1.50.94\brave_vpn_helper.exe" --crash-me` (or similar) 5. launch Brave 6. connect to `Brave VPN` 7. press `ctrl` + `alt` + `del` to open `Task Manager` 8. context click on one of the column headings 9. toggle `Command line` on 10. look for the `brave_vpn_helper.exe` process that's launched with `--type=crashpad-handler` 11. toggle `Brave VPN` to `Disconnected` 12. toggle `Brave VPN` to `Connected` 13. confirm the `brave_vpn_helper.exe` process disappears from the `Task Manager` (as it crashed) 14. open `C:\ProgramData\BraveSoftware\BraveBetaVpnService\Crashpad\reports` 15. confirm crash-report .dmp (dump) files populate the above folder for each crash 16. grab a `.dmp` filename 17. load `https://brave.sp.backtrace.io/` 18. enter basic auth 19. set the filters to `upload_file_minidump` `equal_to` `dump-filename` (without the `.dmp` extension) 20. press `enter` 21. confirm crash-dump report loads example | example | example ----------|---------|--------- image|image|image https://user-images.githubusercontent.com/98358127/230162213-37c93ce6-2945-40f0-89fa-c5421f955a91.mp4

Non-admin installed Brave

DoH fallback - PASSED

1. double-click on the appropriate `beta` build's ` installer 2. when prompted by Windows to allow the app to make changes, click `No` 3. click `Yes` on the `Brave-Browser-Beta can be installed without administrator privileges. Continue?` dialog 4. configure `Brave VPN` 5. launch Brave 6. connect to `Brave VPN` 7. press `ctrl` + `alt` + `del` to open `Task Manager` 8. ensure there's no `Brave VPN Helper` service/process running 9. load `https://browserleaks.com/dns` 10. confirm under `ISP` your local ISP's DNS resolvers aren't shown (should be Cloudflare) 11. open `brave://settings/security` 12. confirm it says `This setting is locked by BraveVPN while it is connected`, under `Use Secure DNS` `Task Manager`| `browserleaks.com/dns` | `brave://settings/security` ----------|----------|------------- image|image|image
GeetaSarvadnya commented 1 year ago

Verification PASSED on

Brave | 1.50.114 Chromium: 112.0.5615.49 (Official Build) (64-bit)
-- | --
Revision | bd2a7bcb881c11e8cfe3078709382934e3916914-refs/branch-heads/5615@{#936}
OS | Windows 11 Version 22H2 (Build 22621.1413)

Admin-installed Brave

Brave VPN Helper-service dynamic launching - PASSED

Steps: 1. (with Brave VPN installed as Admin, and configured) 2. launch Brave 3. click on the `VPN` button 4. toggle VPN to `Connected` 5. press `ctrl` + `alt` + `del` 6. click on `Task Manager` 7. confirm the presence of `Brave VPN Helper` service processes 8. disconnect and reconnect `Brave VPN` 9. confirm you see the processes disappear and then re-appear **_VPN ON_** Brave VPN service | Brave VPN helper process | VPN ON ---------------------|-----------|--------- ![image](https://user-images.githubusercontent.com/38657976/230116300-df352103-e4cf-49d0-9b16-c694f39da845.png) | ![image](https://user-images.githubusercontent.com/38657976/230116499-4e0b830c-3b47-42b7-99fe-a2c23c57be3b.png) | ![image](https://user-images.githubusercontent.com/38657976/230117994-bf741859-e1ac-423d-ba4d-c1e367e587e4.png) **_VPN OFF_** VPN OFF | Brave VPN service ---------------------|----------- ![image](https://user-images.githubusercontent.com/38657976/230117554-b54f20bb-49fc-44a8-a88d-12d2d82ad3d4.png) | ![image](https://user-images.githubusercontent.com/38657976/230117683-7a390986-2500-4d10-b830-de59378b1b49.png)

Brave VPN Helper-service process kill & respawn - PASSED

Steps: 1. (with Brave VPN installed as Admin, and configured) 2. launch Brave 3. connect to `BraveVPN` 4. open the `Task Manager` via `ctrl` + `alt` + `del` 5. look for the `BraveVpnService` process under service in task manager 6. kill the helper service executable by clicking `End task` in `Task Manager` 7. confirm the service automatically restarts after crash 8. repeat a few times to kill it again and check the service will be restarted 3 times in total 9. after killing the service the 4th time, it should not be restarted again 10. disconnect/Connect VPN again from Brave Browser and check it uses overridden DoH instead of VPN service. DNS leak should not happen. Example | Example | Example | Example ----------|-----------|-----------|---------- ![image](https://user-images.githubusercontent.com/38657976/230119240-49b0df06-a720-45fb-b273-dcab88705f9e.png) | ![image](https://user-images.githubusercontent.com/38657976/230119493-603d2ddd-4150-455c-8903-8ab0ad08db52.png) | ![image](https://user-images.githubusercontent.com/38657976/230119638-9a28f181-cfd6-49ea-ba07-05e0736c4071.png) | ![image](https://user-images.githubusercontent.com/38657976/230120490-a35eff99-504a-49cd-a7bc-ffc55ba79f07.png)

Non-admin installed Brave

DoH fallback - PASSED

1. double-click on the appropriate `beta` build's ` installer 2. when prompted by Windows to allow the app to make changes, click `No` 3. click `Yes` on the `Brave-Browser-Beta can be installed without administrator privileges. Continue?` dialog 4. configure `Brave VPN` 5. launch Brave 6. connect to `Brave VPN` 7. press `ctrl` + `alt` + `del` to open `Task Manager` 8. ensure there's no `Brave VPN Helper` service/process running 9. load `https://browserleaks.com/dns` 10. confirm under `ISP` your local ISP's DNS resolvers aren't shown (should be Cloudflare) 11. open `brave://settings/security` 12. confirm it says `This setting is locked by BraveVPN while it is connected`, under `Use Secure DNS` `Task Manager`| `browserleaks.com/dns` | `brave://settings/security` ----------|----------|------------- ![image](https://user-images.githubusercontent.com/38657976/230145774-600faa18-384c-4f60-9e20-e2d633d630b7.png) | ![image](https://user-images.githubusercontent.com/38657976/230145823-e064d1ec-da6f-420a-895a-7aa8ab6dd1bb.png) | ![image](https://user-images.githubusercontent.com/38657976/230145925-96efe702-bb7e-447f-9b29-b8fc8c0ce5da.png)