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

Don't reveal chrome-untrusted:// and other parents in ancestorOrigins. #20792

Merged
merged 2 commits into from
Nov 7, 2023

Conversation

goodov
Copy link
Member

@goodov goodov commented Nov 1, 2023

Resolves brave/brave-browser#34033

Submitter Checklist:

  • I confirm that no security/privacy review is needed and no other type of reviews are needed, or that I have requested them
  • 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 wiki
    • npm run lint, npm run presubmit wiki, 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:

@goodov goodov force-pushed the fix-ancestors-origins-for-player branch from 4c97c40 to 2f16868 Compare November 1, 2023 09:54
@goodov goodov marked this pull request as ready for review November 1, 2023 11:40
@goodov goodov requested a review from a team as a code owner November 1, 2023 11:40
@goodov goodov requested review from pes10k and bridiver November 1, 2023 11:41
@iefremov
Copy link
Contributor

iefremov commented Nov 3, 2023

@goodov fyi #20622

@goodov goodov force-pushed the fix-ancestors-origins-for-player branch from 2f16868 to 224ecbb Compare November 3, 2023 14:40
@goodov goodov added the CI/run-upstream-tests Run upstream unit and browser tests on Linux and Windows (otherwise only on Linux) label Nov 3, 2023
@goodov goodov force-pushed the fix-ancestors-origins-for-player branch from 224ecbb to 7493df7 Compare November 4, 2023 09:20
@goodov goodov added CI/run-linux-arm64 Run CI builds for Linux arm64 CI/run-windows-arm64 Run CI builds for Windows arm64 labels Nov 4, 2023
@goodov goodov enabled auto-merge November 4, 2023 13:34
@goodov goodov force-pushed the fix-ancestors-origins-for-player branch from 7493df7 to ab6f3fd Compare November 6, 2023 16:29
@goodov goodov removed the CI/run-upstream-tests Run upstream unit and browser tests on Linux and Windows (otherwise only on Linux) label Nov 7, 2023
@goodov goodov merged commit 775f903 into master Nov 7, 2023
@goodov goodov deleted the fix-ancestors-origins-for-player branch November 7, 2023 06:54
@github-actions github-actions bot added this to the 1.62.x - Nightly milestone Nov 7, 2023
auto* raw_origins = ancestorOrigins_ChromiumImpl();
for (uint32_t i = 0; i < raw_origins->length(); ++i) {
const String raw_origin = raw_origins->item(i);
const scoped_refptr<SecurityOrigin> origin =
SecurityOrigin::CreateFromString(raw_origin);
if (is_chrome_untrusted(origin.get())) {
break;
Copy link
Member

Choose a reason for hiding this comment

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

Sorry for missing that during the review, but shouldn't we use continue here instead?
I think we want to remove chrome-untrusted from the list, but if there are multiple nesting levels, then we should probably leave the other ones there.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry for missing that during the review, but shouldn't we use continue here instead? I think we want to remove chrome-untrusted from the list, but if there are multiple nesting levels, then we should probably leave the other ones there.

we explicitly don't want the player iframe to know its nested level (how many iframes deep it's running).

I don't think we want to reveal this info to any iframe inside chrome-untrusted://.

Copy link
Member

Choose a reason for hiding this comment

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

Just to be clear, I was not suggesting adding "null" entries in this case, just omitting the chrome-untrusted entries instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

Just to be clear, I was not suggesting adding "null" entries in this case, just omitting the chrome-untrusted entries instead.

yep, but this way the ancestorOrigins will still contain the top frame, which is chrome://player. We also don't want this.

Copy link
Member

Choose a reason for hiding this comment

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

And it would be fine to remove chrome:// URLs in a similar way IMO.

So basically I think we should do one of two things:

  1. Remove chrome-untrusted and chrome untrusted entries from ancestorOrigins in all cases, but leave the other entries alone. This would apply all of the time.
  2. Clear ancestorOrigins entirely, but only for chrome://player.

With #1, it would mean that if we have nested iframes like:

 chrome://player => chrome-untrusted://whatever => https://example.com => https://targetsite.com

then targetsite.com would see the same ancestorOrigins as in the normal web case:

https://example.com => https://targetsite.com

#2 on the other hand would solve the immediate problem without affecting anything else.

Copy link
Member Author

Choose a reason for hiding this comment

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

With #1, it would mean that if we have nested iframes like:

 chrome://player => chrome-untrusted://whatever => https://example.com => https://targetsite.com

then targetsite.com would see the same ancestorOrigins as in the normal web case:

https://example.com => https://targetsite.com

This example should already work like you described. The chain will be left intact until chrome-untrusted:// is encountered, so https://example.com => https://targetsite.com chain will stay. The order in the chain list is reversed: first we get https://targetsite.com, then https://example.com, then chrome-untrusted://. We stop at chrome-untrusted:// item, this means the "good" https:// chain is there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/run-linux-arm64 Run CI builds for Linux arm64 CI/run-windows-arm64 Run CI builds for Windows arm64
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't reveal chrome-untrusted:// in ancestorOrigins
3 participants