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

Add Constellation/STAR encryption for P3A #14399

Merged
merged 32 commits into from
Apr 6, 2023
Merged

Add Constellation/STAR encryption for P3A #14399

merged 32 commits into from
Apr 6, 2023

Conversation

DJAndries
Copy link
Collaborator

@DJAndries DJAndries commented Jul 29, 2022

Resolves brave/brave-browser#24338

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:

Please test in a version that includes #18340 or #18410.

Access https://star-randsrv.bsg.brave.software/info and note the currentEpoch value.

Perform this first test without a MITM proxy (Nitro Enclave attestation will not work without proxy).

  1. Start browser with a fresh profile and the following flags: --enable-features="BraveP3AConstellation" --p3a-star-randomness-host=https://star-randsrv.bsg.bravesoftware.com --p3a-constellation-upload-url=https://collector.bsg.bravesoftware.com/
  2. Access local state, validate the following details: brave.p3a.approved_cert_fp should contain a value prefixed with sha256/, brave.p3a.current_epoch should contain the value noted above, brave.p3a.current_pk should contain a long string, brave.p3a.next_epoch_time should contain a numerical timestamp value, p3a.logs_constellation_prep should exist with the typical list of metrics/values/etc.
  3. Wait five minutes and reload local state page. p3a.constellation_logs.{epoch number} should contain a list of metrics with the name as the key, and the encrypted base-64 value as the value. A new log should appear in the list every minute. Verify that the relevant metrics in the p3a.logs_constellation_prep list indicate being sent.
  4. Quit the browser and add the following flag when restarting --p3a-fake-star-epoch=. Add one to the current epoch and append the value to the flag.
  5. Access local state, validate that the metrics still exist in p3a.constellation_logs.{original epoch number}.
  6. Wait five minutes and refresh the local state page. The Constellation logs object should contain less metric than before (because the encrypted metrics were uploaded to our server and no longer need to be stored).
  7. Repeat steps 0 - 2. Repeat step 3 with an epoch value that is 5 or more epochs ahead of the current epoch value. Access local state and ensure the metrics in p3a.constellation_logs.{original epoch number} do not exist (due to expiry).

Perform this second test using a MITM proxy, and add the --p3a-disable-star-attestation flag.

  1. Start browser with a fresh profile and using the flags mentioned in step 0 from the first test.
  2. Ensure that an /info request is sent to the randomness server.
  3. Wait a few minutes, ensure that /randomness requests are sent to the randomness server. Ensure that the number of metrics existing in the Constellation logs (in local state) matches the number of randomness requests sent. Ensure no requests are sent to the upload url.
  4. Quit the browser and relaunch, ensure that the info request is not sent (server info should be cached).
  5. Add the fake STAR epoch flag and relaunch the browser, add one to the current epoch like above.
  6. An /info request should be sent. Encrypted metrics should be uploaded to the upload URL after a few minutes. Randomness requests should fail since the current fake epoch is not valid.

Ensure JSON metrics are sent as usual with or without the Constellation feature enabled.

@DJAndries DJAndries requested review from iefremov, fmarier, a team and bridiver as code owners July 29, 2022 17:19
@github-actions github-actions bot added the CI/run-audit-deps Check for known npm/cargo vulnerabilities (audit_deps) label Jul 29, 2022
Copy link
Member

@kdenhartog kdenhartog left a comment

Choose a reason for hiding this comment

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

Few questions in here, but nothing major stands out to me for this

components/nested_star/src/lib.rs Outdated Show resolved Hide resolved
components/nested_star/src/lib.rs Outdated Show resolved Hide resolved
components/nitro_utils/attestation.cc Outdated Show resolved Hide resolved
components/nitro_utils/attestation.cc Outdated Show resolved Hide resolved
components/nitro_utils/attestation.cc Outdated Show resolved Hide resolved
components/p3a/brave_p3a_rotation_scheduler.cc Outdated Show resolved Hide resolved
components/p3a/brave_p3a_star.cc Outdated Show resolved Hide resolved
components/p3a/brave_p3a_star_log_store.cc Outdated Show resolved Hide resolved
components/p3a/brave_p3a_star_randomness_points.cc Outdated Show resolved Hide resolved
components/p3a/p3a_message.cc Outdated Show resolved Hide resolved
@DJAndries DJAndries force-pushed the p3a-star-v2 branch 4 times, most recently from 491f29f to e590d91 Compare August 2, 2022 20:34
Copy link
Member

@kdenhartog kdenhartog left a comment

Choose a reason for hiding this comment

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

My comments have been addressed. Approving

@fmarier feel free to close this one out once you're satisfied with it

@DJAndries DJAndries force-pushed the p3a-star-v2 branch 3 times, most recently from c9fa07b to a477fae Compare April 4, 2023 02:15
…ponse/server unavailability, misc feedback updates for p3a config
@DJAndries
Copy link
Collaborator Author

Will perform smoke tests before merge

@rillian
Copy link
Contributor

rillian commented Apr 6, 2023

How's this going? It would be good to get this merged so other code can build on it. Since it's disabled by default, it should be fine to land as long as it hasn't broken the default experience.

@DJAndries
Copy link
Collaborator Author

How's this going? It would be good to get this merged so other code can build on it. Since it's disabled by default, it should be fine to land as long as it hasn't broken the default experience.

i intend on merging this later today

@DJAndries DJAndries merged commit 1419225 into master Apr 6, 2023
@DJAndries DJAndries deleted the p3a-star-v2 branch April 6, 2023 23:40
@github-actions github-actions bot added this to the 1.52.x - Nightly milestone Apr 6, 2023
@rillian
Copy link
Contributor

rillian commented Apr 17, 2023

@DJAndries would you be able to write a test plan for QA?

@DJAndries
Copy link
Collaborator Author

@DJAndries would you be able to write a test plan for QA?

updated now that #18340 has landed

}

content::BrowserTaskEnvironment task_environment_;
network::TestURLLoaderFactory url_loader_factory;
Copy link
Collaborator

Choose a reason for hiding this comment

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

These variables are not named according to convention required by the the style guide [1]. I'm flagging this to raise some awareness, to authors and reviewers, as I've come across a few places today where such cases seemed to have got into master.

I also think we could there are some area for improvement about which members should have been kept private, or protected.

[1] https://google.github.io/styleguide/cppguide.html#Variable_Names

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/run-audit-deps Check for known npm/cargo vulnerabilities (audit_deps)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Constellation/STAR encryption for P3A