brave / brave-browser

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

Nebula: add differential privacy sampling to P3A #35841

Closed rillian closed 4 months ago

rillian commented 9 months ago

Description

Per recent discussions, we want to add differential privacy to the STAR protocol used to report how features are used in the browser. The first phase of this is just to add sampling to the current reports: some percentage of the time the client submits a measurement with the value or tag of the outer layer replaced with some random value. This addresses some of the leakage from undecodable tags in STAR by adding plausible deniability to the threshold anonymity.

Proposed parameters, derived from differential privacy ε=1 and δ = 10^-8:

By introducing sampling we enforce better privacy bounds even with the lower aggregation threshold (currently K=50).

Rough plan

rillian commented 9 months ago

cc @AliShahin @DJAndries

kjozwiak commented 4 months ago

The above requires 1.68.101 or higher for 1.68.x verification 👍

GeetaSarvadnya commented 4 months ago

Verification PASSED on

Brave | 1.68.101 Chromium: 126.0.6478.126 (Official Build) beta (64-bit)
-- | --
Revision | ffa8411f4c8fe36c0e399f60ef7c24b3cf7d7402
OS | Windows 10 Version 22H2 (Build 19045.4529)

Test Plan

Test plan verification_PASSED - Confirmed that each collector request have the ` Brave-P3A-Constellation-Threshold` header value `20` or `50` slow | express | typical | slow | express | typical ------|---------|-------|------|------|------ ![image](https://github.com/brave/brave-browser/assets/38657976/bf8230e1-d7bd-4fd8-b341-cfe3fcc2f9f4) | ![image](https://github.com/brave/brave-browser/assets/38657976/79c88140-1669-4a89-a404-6462e8325cbf) | ![image](https://github.com/brave/brave-browser/assets/38657976/92677b80-f05f-4ded-8889-cc43f8c2950a) | ![image](https://github.com/brave/brave-browser/assets/38657976/2a6f42f9-bb01-4651-9a1e-f19b74110827) | ![image](https://github.com/brave/brave-browser/assets/38657976/aad79d8e-dd42-4d77-a363-bb041e8a3e65) | ![image](https://github.com/brave/brave-browser/assets/38657976/b1a35129-b216-4b4a-b77d-30108dcc20db) To view all the collector metrics metrics Example | Example ----------|---------- ![image](https://github.com/brave/brave-browser/assets/38657976/fc5d7772-a6be-4747-a5df-f99dbf80cff6) | ![image](https://github.com/brave/brave-browser/assets/38657976/f908ff52-db8c-4d6e-ba7b-38f3d46473ec)
GeetaSarvadnya commented 4 months ago

Verification PASSED on Vivo X70 Pro version12 running Bravemonoarm64.apk_1.68.101

Test Plan

Test plan verification_PASSED - Confirmed that each collector request have the ` Brave-P3A-Constellation-Threshold` header value `20` or `50` slow | express | typical | slow | express | typical ------|---------|-------|------|------|------ ![image](https://github.com/brave/brave-browser/assets/38657976/5fe30d56-e338-4643-9094-150a0f4677b9) | ![image](https://github.com/brave/brave-browser/assets/38657976/c1283712-db4b-4af8-8d53-b764a93b5290) | ![image](https://github.com/brave/brave-browser/assets/38657976/5900e356-2982-48ed-9546-ec3dd54fd85a) | ![image](https://github.com/brave/brave-browser/assets/38657976/0c4375ab-55e7-4637-b7de-2b1a44170af3) | ![image](https://github.com/brave/brave-browser/assets/38657976/34a4d365-7c6c-4454-a969-3346f81717c8) | ![image](https://github.com/brave/brave-browser/assets/38657976/b6e0979e-d899-432f-a4ce-7287830e68ab) To view all the collector metrics metrics Example | Example ----------|---------- ![image](https://github.com/brave/brave-browser/assets/38657976/19929cb2-ee0f-4aa9-ae57-2daf95eeb813) | ![image](https://github.com/brave/brave-browser/assets/38657976/40afe6dd-8968-4976-9ae1-5c1b5d27bc77)

Regression test

Step 1_PASSED - Confirmed that JSON metrics are sent as usual to the endpoint http://p3a-json.brave.com/ - Confirmed that each metric is sent to the server and marked as "sent" = `true` in the local state file randomness metrics at `http://p3a-json.brave.com/` ![image](https://github.com/brave/brave-browser/assets/38657976/be35bca0-5835-4d91-842b-7e2a00489b12) - Confirmed that if the metric is in the `logs` object (in local state), then the cadence is `typical` and the same is displayed in p3a-json.brave.com endpoint in the server **Note**: `Typical` metrics are NOT listed under the `Logs` block on brave://local-state file, also few metrics are listed under `http://p3a-json.brave.com/` endpoint which is correct as `http://p3a-json.brave.com/` will be deprecated soon. We are good if all the metrics are shown under `logs_constellation_prep` block - Confirmed that, If the metric is in `logs_slow` then the `cadence` is slow and same is displayed in the p3a-json.brave.com endpoint in the server - Confirmed that, If the metric is in `logs_express` then the cadence is `express` and the same is displayed in p3a-json.brave.com endpoint in the server - Only 3 metrics are shown under the `logs_express` but in p3a-json endpoint, I could see only two cadence `express` metrics sent to the endpoint `p3a-json.brave.com` and one metric is sent to the endpoint `https://p3a-creative.brave.com` Example | Example | Example | `https://p3a-creative.brave.com` ----------|----------|----------|-------- ![Screenshot_20240704_155113](https://github.com/brave/brave-browser/assets/38657976/bf50213e-5f32-46d6-b18d-d1e08067c520) | ![image](https://github.com/brave/brave-browser/assets/38657976/5149f9b3-f70e-4934-b143-62de65aa09f1) | ![image](https://github.com/brave/brave-browser/assets/38657976/f7973057-a6db-472f-b4ea-dbcf7d6d3f33) | ![image](https://github.com/brave/brave-browser/assets/38657976/3cb71e8a-93b9-4d55-8c3c-ec4b4115e0e3) - Only 4 metrics are shown under `logs_slow` both metrics are shown under https://p3a-json.brave.com as expected Example | Example | Example | Example | Example ----------|----------|----------|---------|--------- ![Screenshot_20240704_155119](https://github.com/brave/brave-browser/assets/38657976/50338735-6ecf-4159-a640-b15df25ca1cd) | ![image](https://github.com/brave/brave-browser/assets/38657976/ce180bf9-93ed-489d-b313-4a0275f6da5f) | ![image](https://github.com/brave/brave-browser/assets/38657976/10aad217-df4b-49bd-9335-45ebab4792aa) | ![image](https://github.com/brave/brave-browser/assets/38657976/1e4a6fb3-d850-4ce6-b6ed-f7d83dec3977) | ![image](https://github.com/brave/brave-browser/assets/38657976/f96f4a37-2d90-4933-8482-890833b0e548) - Confirmed that the cadence field in the payload contains the correct value - The metrics `Brave.Shields.AdBlockSettings` response value is `1` in both local state file and `p3a-json...` endpoint
Step 2_PASSED 1. Confirmed that requests are being made to `star-randsrv.bsg.brave.com` to prepare Constellation metrics 2. Confirmed that the URL path is `/instances//randomness` 3. Confirmed that when one request is `sent` for a particular cadence, check to see that metrics are being marked as "sent" as they are being sent to the server, by checking the correct "logs" object in local state. **46 randomness** requests are sent to this endpoint `star-randsrv.bsg.brave.com` Step 1,2 | Step 1, 2(1) ----------|------------- ![image](https://github.com/brave/brave-browser/assets/38657976/da168b2e-deeb-46fc-b50c-f34014c36ad2) | ![image](https://github.com/brave/brave-browser/assets/38657976/6d7fd7e8-a39e-4f4a-8577-a219ea9499d2) **46 typical logs** metrics are shown under `Logs` in brave://local-state Step 3 | Step 3(1) | Step 3(2) --------|-----------|----------- No `Logs` in brave://local-state 4. There are `46 metrics` listed under `Logs` as shown in the images above `Step 3`, `Step 3(1)` and `Step 3(2)` and `46 metrics` are listed under `logs_constellation_prep` shown in the images below `Step 4(1)`, `Step 4(2)` and `Step 4(3)` All the metrics under `Logs` and `logs_constellation_prep` are marked as `sent:true`, when we look at the `https://star-randsrv.bsg.brave.com` endpoint at the server, `46 typical metrics` are sent to the server in the form of `randomness` instances as shown in the images above `Step 1,2(1)` and `Step 1,2(2)` 46 metrics are shown under `logs_constellation_prep` Step 4(1) | Step 4(2) | Step 4(3) | Step 4(4) ----------|------------|----------|------------ ![Screenshot_20240704_155146](https://github.com/brave/brave-browser/assets/38657976/fae2cbd0-94d0-4e3a-a9d8-598f36d24616) | ![Screenshot_20240704_155152](https://github.com/brave/brave-browser/assets/38657976/2fde3130-28b3-4246-904e-f6d92f8e77b8) | ![Screenshot_20240704_155201](https://github.com/brave/brave-browser/assets/38657976/6ca32f99-6cfa-4393-80a0-70bee376e19a) | ![Screenshot_20240704_155227](https://github.com/brave/brave-browser/assets/38657976/daca01a6-d1f7-4f4f-b4ad-07adf41b8077) 5. Confirmed that no. of metrics shown under `logs_constellation_prep_express` are same as the no. of metrics shown under `logs_express` and `express` instances at the `star-randsrv.bsg.brave.com` server endpoint as expected `logs_constellation_prep_express` | `logs_express` | `express` -------------------------------------|-----------------|------------- ![Screenshot_20240704_155134](https://github.com/brave/brave-browser/assets/38657976/112c740c-0b2c-4b1c-9d15-ad4d5b604075) | ![Screenshot_20240704_155113](https://github.com/brave/brave-browser/assets/38657976/8c6bdd89-c251-4184-8dea-d3248781ff1a) | ![image](https://github.com/brave/brave-browser/assets/38657976/6d7fd7e8-a39e-4f4a-8577-a219ea9499d2) 6. Confirmed that no. of metrics shown under `logs_constellation_prep_slow` are same as the no. of metrics shown under `logs_slow` and `slow` instances at the `star-randsrv.bsg.brave.com` server endpoint as expected `logs_constellation_prep_slow` | `logs_slow` | `slow` -------------------------------------|-----------------|------------- ![Screenshot_20240704_155125](https://github.com/brave/brave-browser/assets/38657976/298f9685-61e8-4b2c-a2c3-9a556d7813f8) | ![Screenshot_20240704_155119](https://github.com/brave/brave-browser/assets/38657976/cc568ea3-f564-4fb6-a9c3-dab5495ed12c) | ![image](https://github.com/brave/brave-browser/assets/38657976/9eba273e-6b95-4b2b-9c95-73dd105c377e)
Step 3_PASSED ``` Ensure final measurements are being sent to collector.bsg.brave.com. The URL path should be /. Before metrics are sent to this server, they should appear under constellation_logs, constellation_logs_express and constellation_logs_slow after being prepared (from the requests being made in step 2). As soon as the metrics are sent to the collector, the metric should disappear in the relevant local state object. ``` 1. Confirmed that, before the metrics are sent to server they are prepared to sent and hence appear under `logs_constellation_prep_express`, `logs_constellation_prep_slow` and `logs_constellation_prep` after that the metrics are appear under `constellation_logs`, `constellation_logs_express` and `constellation_logs_slow `. But the metrics listed under `constellation_logs`, `constellation_logs_express` and `constellation_logs_slow ` are removed once the metrics are sent to the server **_metrics prepared_** Example | Example | Example | Example | Example | Example ----------|-----------|---------|-----------|-----------|---------- ![Screenshot_20240704_155125](https://github.com/brave/brave-browser/assets/38657976/6133e35a-70a2-4cc3-910c-faa5ea462033) | ![Screenshot_20240704_155134](https://github.com/brave/brave-browser/assets/38657976/15a20d80-53e0-4cb4-851f-2d045fe51c47) | ![Screenshot_20240704_155146](https://github.com/brave/brave-browser/assets/38657976/03ec40e4-18d7-44c5-b063-2dd4f5a0e943) | ![Screenshot_20240704_155201](https://github.com/brave/brave-browser/assets/38657976/48b1d32b-61d7-4968-b0f9-d0984b47dd52) | ![Screenshot_20240704_155201](https://github.com/brave/brave-browser/assets/38657976/9633e1d8-3758-42f0-b5f1-7a854543768c) | ![Screenshot_20240704_155227](https://github.com/brave/brave-browser/assets/38657976/26ca1fde-ae94-46e5-9d87-9752564ce552) **_constellation logs_** ![Screenshot_20240704_155644](https://github.com/brave/brave-browser/assets/38657976/133b6f28-ba10-42dc-a638-240aa7d78cd5) 2. Confirmed that the final measurements are sent to the endpoint `collector.bsg.brave.com` - Two `slow` metrics are sent to the endpoint `collector.bsg.brave.com` as expected - Two `express` metrics are sent to the endpoint `collector.bsg.brave.com` instead of three - There is one `creative` cadence type metrics are sent to the endpoint `collector.bsg.brave.com` - Not sure whether this is expected or not there is no mention of this metrics in the test plan (this is expected as per the response below) - There are `46 typical` metrics are sent to the endpoint `collector.bsg.brave.com` as there are `46 typical` metrics are listed under `Logs` in brave://local-state file Example | Example | Example ---------|------------|------- ![image](https://github.com/brave/brave-browser/assets/38657976/df5383a1-5b5b-4dd7-851c-3e21669f27f3) ![image](https://github.com/brave/brave-browser/assets/38657976/3b1005fa-ae79-4266-beb6-8251c0e2297a) ![image](https://github.com/brave/brave-browser/assets/38657976/c171384e-6e36-4118-8888-1c605c7a9b09)