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

climb frame tree to determine top level eTLD+1 when generating farble seed #5877

Merged
merged 1 commit into from
Jun 17, 2020

Conversation

pes10k
Copy link
Contributor

@pes10k pes10k commented Jun 17, 2020

This PR tries to solve a problem where we were using garbage memory sometimes when generating the farble seed, by trying to climb the frame tree. I hope i got it right…

Should fix brave/brave-browser#10260

@pes10k pes10k requested a review from bridiver as a code owner June 17, 2020 02:49
@pes10k pes10k requested a review from pilgrim-brave June 17, 2020 02:49
return "";
}

return top_sec_ctx->GetSecurityOrigin()->RegistrableDomain().Utf8();
Copy link
Contributor

Choose a reason for hiding this comment

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

RegistrableDomain is not what we want. See examples in https://url.spec.whatwg.org/#host-registrable-domain

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed!

// are disconnect, remote or local to the top level frame.
//
// If the top level frame is not discoverable, an empty string is returned.
std::string topETLDPlusOneForDoc(const Document& doc) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this method name should be capitalized

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

}

const std::string host = top_sec_ctx->GetSecurityOrigin()->Host().Utf8();
return net::registry_controlled_domains::GetDomainAndRegistry(
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should be using network_utils::GetDomainAndRegistry in blink

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okie, moved to network_utils::GetDomainAndRegistry

// frame that the given document is in. This includes frames that
// are disconnect, remote or local to the top level frame.
//
// If the top level frame is not discoverable, an empty string is returned.
Copy link
Collaborator

Choose a reason for hiding this comment

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

when does this happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't know all the cases, but I updated the comment to include an example

// This can happen in cases including frames that are not connected
// to the document, or iframes that are accessed while they're moving
// between processes (e.g., a frame's url is being changed to
// be LocalFrame to a RemoveFrame, or vise versa).
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove -> Remote

std::string TopETLDPlusOneForDoc(const Document& doc) {
const auto* top_loc_frame = doc.GetFrameOfMasterDocument();
if (top_loc_frame == nullptr) {
LOG(ERROR) << "Unable to farble frame bc can't find top local frame: "
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we have a DCHECK here to see if it's still happening with this change or do we still expect it to be null in some cases?

@pes10k pes10k force-pushed the change-farbling-origin-lookup branch from e8c429c to b093351 Compare June 17, 2020 22:42
@pes10k pes10k force-pushed the change-farbling-origin-lookup branch from b093351 to 63d585b Compare June 17, 2020 22:52
@pes10k pes10k self-assigned this Jun 17, 2020
@pes10k pes10k merged commit ee1270d into master Jun 17, 2020
@pes10k pes10k deleted the change-farbling-origin-lookup branch June 17, 2020 23:22
@pes10k pes10k added this to the 1.12.x - Nightly milestone Jun 17, 2020
bsclifton pushed a commit that referenced this pull request Jun 18, 2020
climb frame tree to determine top level eTLD+1 when generating farble seed
bsclifton pushed a commit that referenced this pull request Jun 18, 2020
climb frame tree to determine top level eTLD+1 when generating farble seed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Desktop] Fingerprint values for Web audio is not the same on both pages with Shields down, follow up of #9186
3 participants