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

Use localhost-permission-allow-list.txt to decide which websites to prompt for #30121

Closed
ShivanKaul opened this issue May 4, 2023 · 5 comments · Fixed by brave/brave-core#18354

Comments

@ShivanKaul
Copy link
Collaborator

ShivanKaul commented May 4, 2023

If localhost permission is not already given, only prompt if requesting URL is on allowlist which will be shipped as a component update.

  1. This list will live at https://github.com/brave/adblock-lists/tree/master/brave-lists. PR: Create localhost-permission-allow-list.txt adblock-lists#1156
  2. The localhost-permission-allow-list.txt will be bundled in Brave Local Data Updater similar to debounce.json or https-exceptions-list.txt. PR: Package localhost-permission-allow-list.txt brave-core-crx-packager#620
  3. Currently localhost connections are blocked via adblock: https://github.com/brave/adblock-lists/blob/master/brave-lists/brave-specific.txt#L1-L12. We will remove those once we have the new list in place.

If a user goes into brave://settings/content/localhostAccess and adds a website to Allow or Deny we should honour that first.

@kjozwiak
Copy link
Member

kjozwiak commented Jun 1, 2023

@brave/qa-team this one can be completed at the same alongside #30151.

@stephendonner stephendonner added the QA/In-Progress Indicates that QA is currently in progress for that particular issue label Jun 2, 2023
@stephendonner
Copy link

stephendonner commented Jun 2, 2023

Verification PASSED using

Brave 1.53.76 Chromium: 114.0.5735.90 (Official Build) beta (64-bit)
Revision 386bc09e8f4f2e025eddae123f36f6263096ae49-refs/branch-heads/5735@{#1052}
OS Windows 10 Version 22H2 (Build 19045.3031)

Shared Steps:

  1. installed 1.53.76
  2. launched Brave
  3. set brave://flags/#brave-localhost-access-permission to Enabled
  4. clicked Relaunch
  5. added the following:
# https://shivankaul.com/brave/localhost/
shivankaul.com
  1. to localhost-permission-allow-list.txt in C:\Users\steph\AppData\Local\BraveSoftware\Brave-Browser-Beta\User Data\afalakplffnnnlkncjhbmahjfjhmlkal\1.0.342\1
  2. created a tests dir on my desktop
  3. placed a logo.png file in the same directory
  4. ran python3 -m http.server 8000, also from tests
example example example
image image image

Subresource test - PASSED

(continued from Shared Steps)

  1. added @@||localhost^$domain=shivankaul.com to Create custom filters in brave://settings/shields/filters
  2. loaded https://shivankaul.com/brave/localhost/subresource.html
  3. confirmed I was prompted to Allow or Block
  4. clicked Allow
  5. confirmed my logo.png loaded
  6. confirmed https://shivankaul.com:443 appeared under Allowed to access localhost resources, in brave://settings/content/localhostAccess
  7. repeated, this time clicking Block
  8. confirmed logo.png showed a broken-image placeholder
  9. confirmed https://shivankaul.com:443 appeared under Not allowed to access localhost resources in brave://settings/content/localhostAccess
Custom filter rule localhost-permission prompt Allowed Blocked Allowed to access... Not allowed to access...
image image image image image image

iframe test - PASSED

(continued from Shared Steps)

  1. loaded https://shivankaul.com/brave/localhost/iframe.html
  2. confirmed I was prompted to Allow or Block
  3. clicked Allow
  4. confirmed my logo.png loaded
  5. confirmed https://shivankaul.com:443 appeared under Allowed to access localhost resources, in brave://settings/content/localhostAccess
  6. repeated, this time clicking Block
  7. confirmed logo.png showed a broken-image placeholder
  8. confirmed https://shivankaul.com:443 appeared under Not allowed to access localhost resources in brave://settings/content/localhostAccess
Custom filter rule localhost-permission prompt Allowed Redirect Blocked Allowed to access... Not allowed to access...
image image image image image image image

localhostAccess-priority test - PASSED

(continued from Shared Steps)

Allowed test case

  1. added shivankaul.com to Allowed to access localhost resources, in brave://settings/content/localhostAccess
  2. loaded https://shivankaul.com/brave/localhost/subresource.html
  3. confirmed no localhost-permissions prompt dialog

Confirmed logo.png rendered

example example
image image

Not allowed test case

  1. added shivankaul.com to Not allowed to access localhost resources in brave://settings/content/localhostAccess
  2. loaded https://shivankaul.com/brave/localhost/subresource.html
  3. confirmed no localhost-permissions prompt dialog

Confirmed logo.png didn't render; only a broken-image icon, in its place

example example
image image

@stephendonner stephendonner added QA Pass-Win64 QA/In-Progress Indicates that QA is currently in progress for that particular issue and removed QA/In-Progress Indicates that QA is currently in progress for that particular issue labels Jun 2, 2023
@stephendonner
Copy link

stephendonner commented Jun 5, 2023

Verification PASSED using

Brave 1.53.81 Chromium: 114.0.5735.90 (Official Build) beta (x86_64)
Revision 386bc09e8f4f2e025eddae123f36f6263096ae49-refs/branch-heads/5735@{#1052}
OS macOS Version 11.7.7 (Build 20G1345)

Shared Steps:

  1. installed 1.53.81
  2. launched Brave
  3. set brave://flags/#brave-localhost-access-permission to Enabled
  4. clicked Relaunch
  5. added the following:
# https://shivankaul.com/brave/localhost/
shivankaul.com
  1. to localhost-permission-allow-list.txt in /Users/stephendonner/Library/Application Support/BraveSoftware/Brave-Browser-Beta/afalakplffnnnlkncjhbmahjfjhmlkal/1.0.344/1
  2. created a tests dir on my desktop
  3. placed a logo.png file in the same directory
  4. ran python3 -m http.server 8000, also from tests
brave://flags localhost-permission-allow-list python3 -m http.server 8000
Screen Shot 2023-06-05 at 3 53 57 PM Screen Shot 2023-06-05 at 3 57 08 PM Screen Shot 2023-06-05 at 4 00 14 PM

Subresource test - PASSED

(continued from Shared Steps)

  1. added @@||localhost^$domain=shivankaul.com to Create custom filters in brave://settings/shields/filters
  2. loaded https://shivankaul.com/brave/localhost/subresource.html
  3. confirmed I was prompted to Allow or Block
  4. clicked Allow
  5. confirmed my logo.png loaded
  6. confirmed https://shivankaul.com:443 appeared under Allowed to access localhost resources, in brave://settings/content/localhostAccess
  7. repeated, this time clicking Block
  8. confirmed logo.png showed a broken-image placeholder
  9. confirmed https://shivankaul.com:443 appeared under Not allowed to access localhost resources in brave://settings/content/localhostAccess
Custom filter rule localhost-permission prompt Allowed Blocked Allowed to access... Not allowed to access...
Screen Shot 2023-06-05 at 4 01 11 PM Screen Shot 2023-06-05 at 4 02 11 PM Screen Shot 2023-06-05 at 4 02 15 PM Screen Shot 2023-06-05 at 4 02 46 PM Screen Shot 2023-06-05 at 4 02 36 PM Screen Shot 2023-06-05 at 4 02 49 PM

iframe test - PASSED

(continued from Shared Steps)

  1. loaded https://shivankaul.com/brave/localhost/iframe.html
  2. confirmed I was prompted to Allow or Block
  3. clicked Allow
  4. confirmed my logo.png loaded
  5. confirmed https://shivankaul.com:443 appeared under Allowed to access localhost resources, in brave://settings/content/localhostAccess
  6. repeated, this time clicking Block
  7. confirmed logo.png showed a broken-image placeholder
  8. confirmed https://shivankaul.com:443 appeared under Not allowed to access localhost resources in brave://settings/content/localhostAccess
Custom filter rule localhost-permission prompt Allowed Redirect Blocked Allowed to access... Not allowed to access...
Screen Shot 2023-06-05 at 4 14 15 PM Screen Shot 2023-06-05 at 4 12 30 PM Screen Shot 2023-06-05 at 4 19 50 PM Screen Shot 2023-06-05 at 4 19 55 PM Screen Shot 2023-06-05 at 4 13 16 PM Screen Shot 2023-06-05 at 4 12 58 PM Screen Shot 2023-06-05 at 4 13 25 PM

localhostAccess-priority test - PASSED

(continued from Shared Steps)

Allowed test case

  1. added shivankaul.com to Allowed to access localhost resources, in brave://settings/content/localhostAccess
  2. loaded https://shivankaul.com/brave/localhost/subresource.html
  3. confirmed no localhost-permissions prompt dialog

Confirmed logo.png rendered

example example
Screen Shot 2023-06-05 at 4 28 30 PM Screen Shot 2023-06-05 at 4 28 48 PM

Not allowed test case

  1. added shivankaul.com to Not allowed to access localhost resources in brave://settings/content/localhostAccess
  2. loaded https://shivankaul.com/brave/localhost/subresource.html
  3. confirmed no localhost-permissions prompt dialog

Confirmed logo.png didn't render; only a broken-image icon, in its place

example example
Screen Shot 2023-06-05 at 4 29 27 PM Screen Shot 2023-06-05 at 4 29 32 PM

@stephendonner stephendonner added QA Pass-macOS and removed QA/In-Progress Indicates that QA is currently in progress for that particular issue labels Jun 5, 2023
@MadhaviSeelam
Copy link

MadhaviSeelam commented Jun 8, 2023

Verification PASSED using

Brave | 1.53.85 Chromium: 114.0.5735.110 (Official Build) beta (64-bit)
-- | --
Revision | 1c828682b85bbc70230a48f5e345489ec447373e-refs/branch-heads/5735_90@{#13}
OS | Linux

Shared Steps:

  1. installed 1.53.85
  2. launched Brave
  3. set brave://flags/#brave-localhost-access-permission to Enabled
  4. clicked Relaunch
  5. added the following:
# https://shivankaul.com/brave/localhost/
shivankaul.com
  1. to localhost-permission-allow-list.txt in ~/.config/BraveSoftware/Brave-Browser-Beta/afalakplffnnnlkncjhbmahjfjhmlkal/1.0.348/1
  2. created a tests dir on my desktop
  3. placed a logo.png file in the same directory
  4. ran python3 -m http.server 8000, also from tests
example example example
Screenshot from 2023-06-08 15-39-59 Screenshot from 2023-06-08 15-46-46 Screenshot from 2023-06-08 16-02-05

Subresource test - PASSED

(continued from Shared Steps)

  1. added @@||localhost^$domain=shivankaul.com to Create custom filters in brave://settings/shields/filters
  2. loaded https://shivankaul.com/brave/localhost/subresource.html
  3. confirmed I was prompted to Allow or Block
  4. clicked Allow
  5. confirmed my logo.png loaded
  6. confirmed https://shivankaul.com:443 appeared under Allowed to access localhost resources, in brave://settings/content/localhostAccess
  7. repeated, this time clicking Block
  8. confirmed logo.png showed a broken-image placeholder
  9. confirmed https://shivankaul.com:443 appeared under Not allowed to access localhost resources in brave://settings/content/localhostAccess
Custom filter rule localhost-permission prompt Allowed Blocked Allowed to access... Not allowed to access...
Screenshot from 2023-06-08 16-05-37 Screenshot from 2023-06-08 16-13-36 Screenshot from 2023-06-08 16-29-47 Screenshot from 2023-06-08 16-30-25 Screenshot from 2023-06-08 16-29-54 Screenshot from 2023-06-08 16-30-33

iframe test - PASSED

(continued from Shared Steps)

  1. loaded https://shivankaul.com/brave/localhost/iframe.html
  2. confirmed I was prompted to Allow or Block
  3. clicked Allow
  4. confirmed my logo.png loaded
  5. confirmed https://shivankaul.com:443 appeared under Allowed to access localhost resources, in brave://settings/content/localhostAccess
  6. repeated, this time clicking Block
  7. confirmed logo.png showed a broken-image placeholder
  8. confirmed https://shivankaul.com:443 appeared under Not allowed to access localhost resources in brave://settings/content/localhostAccess
Custom filter rule localhost-permission prompt Allowed Redirect Blocked Allowed to access... Not allowed to access...
Screenshot from 2023-06-08 16-05-37 Screenshot from 2023-06-08 16-41-39-1 Screenshot from 2023-06-08 16-46-15 Screenshot from 2023-06-08 16-46-21 Screenshot from 2023-06-08 16-45-55 Screenshot from 2023-06-08 16-43-58 Screenshot from 2023-06-08 16-46-00

localhostAccess-priority test - PASSED

(continued from Shared Steps)

Allowed test case

  1. added shivankaul.com to Allowed to access localhost resources, in brave://settings/content/localhostAccess
  2. loaded https://shivankaul.com/brave/localhost/subresource.html
  3. confirmed no localhost-permissions prompt dialog

Confirmed logo.png rendered

example example
Screenshot from 2023-06-09 08-58-24 Screenshot from 2023-06-09 08-58-18

Not allowed test case

  1. added shivankaul.com to Not allowed to access localhost resources in brave://settings/content/localhostAccess
  2. loaded https://shivankaul.com/brave/localhost/subresource.html
  3. confirmed no localhost-permissions prompt dialog

Confirmed logo.png didn't render; only a broken-image icon, in its place

example example
Screenshot from 2023-06-09 08-59-06 Screenshot from 2023-06-09 08-59-00

Disable the setting Sites can request access to localhost resources - PASSED

(continued from Shared Steps)

  1. toggle OFF Sites can request access to localhost resources in brave://settings/content/localhostAccess
  2. load https://shivankaul.com/brave/localhost/subresource.html

Confirmed no localhost-permissions prompt dialog

Confirmed logo.png didn't render; only a broken-image icon, in its place

example example
image image

@hffvld
Copy link
Contributor

hffvld commented Jul 17, 2023

Verified on Pixel 5 using version(s):

Device/OS: Pixel 5 [redfin-userdebug 13 TQ2A.230405.003 dev-keys]
Brave build: 1.56.6
Chromium: 115.0.5790.90 (Official Build) (64-bit)
Revision: 86fb9d04c92b490e6cc0026ca58cb1a98735eea3-refs/branch-heads/5790@{#1583}

Filed issue #31683

STEPS:

  1. Install 1.56.x build > Launch Brave
  2. Set brave://flags/#brave-localhost-access-permission to Enabled > Relaunch Brave
  3. Add the following:
# https://shivankaul.com/brave/localhost/
shivankaul.com
  1. to localhost-permission-allow-list.txt in ~/data/data/com.brave.browser/app_chrome/afalakplffnnnlkncjhbmahjfjhmlkal/1.0.383/1
  2. Install Simple HTTP server (by Phlox Development) from GPS on Android device
  3. Launch the app, allow necessary app permissions and start the server with default values. Confirm status is running
  4. Relaunch Brave app, open new tab and navigate to http://localhost:8000 in the url bar, confirm you are able to access localhost server
  5. Open terminal window and make sure device is connected via adb. Confirm app data folder location for simple http server by using the following command: adb shell ls /storage/emulated/0/Android/data/com.phlox.simpleserver/files
  6. If simple http server is not found in this path, locate it in the device storage by searching in directories in /storage
  7. Download logo.png in the below images and cd into the directory containing the downloaded image. Use this adb command to push the png to the http server root directory in the android device: adb push ./logo.png /storage/emulated/0/Android/data/com.phlox.simpleserver/files/logo.png
  8. Update the tab where localhost is running in brave app and it should now show the logo.png in the root directory. Tap on the file in the list to open the logo image
  9. Navigate to brave://adblock and enter this rule in the custom ad block field @@||localhost^$domain=shivankaul.com
  10. Open https://shivankaul.com/brave/localhost/ and go through the URLs > Verify
1 2 3
1 2 3
1 2 3
1 2 3

ACTUAL RESULTS:

  • Verified that loading subresource https://shivankaul.com/brave/localhost/subresource image test page will prompt user with permission dialog
  • Verified that loading service worker https://shivankaul.com/brave/localhost/sw image test page will prompt user with permission dialog
  • Verified that loading websockets https://shivankaul.com/brave/localhost/ws_client image test page will prompt user with permission dialog
  • Verified that loading iframe https://shivankaul.com/brave/localhost/iframe image test page will prompt user with permission dialog
  • Verified that that allowing localhost permission on test pages will load the resource
  • Verified that Ensured selecting localhost permission will set the appropriate exception for the domain under localhost in site settings
  • that loading https://shivankaul.com/brave/localhost/subresource image test page will prompt user with permission dialog

subresource service worker
1 2
websockets iframe
3 4
Allowed Allowed
5 6
Blocked Blocked
7 8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment