diff --git a/components/guest_view/browser/guest_view_base.cc b/components/guest_view/browser/guest_view_base.cc --- a/components/guest_view/browser/guest_view_base.cc +++ b/components/guest_view/browser/guest_view_base.cc @@ -89,10 +89,21 @@ class GuestViewBase::OwnerContentsObserver : public WebContentsObserver { void RenderFrameHostChanged(content::RenderFrameHost* old_host, content::RenderFrameHost* new_host) override { if (old_host && guest_->owner_rfh_id_ == old_host->GetGlobalId() && new_host && guest_->element_instance_id_ == kInstanceIDNone) { + // SECURITY: Do not transfer ownership across processes. A cross-process + // navigation of the embedder must not silently grant the new (possibly + // cross-origin) renderer the ability to attach to this guest, since + // CanEmbedderAccessInstanceID derives the allowed process from + // owner_rfh() and owner_host_ is not refreshed here. + if (old_host->GetProcess()->GetID() != + new_host->GetProcess()->GetID()) { + guest_->owner_rfh_id_ = content::GlobalRenderFrameHostId(); + DestroyGuestIfUnattached(&*guest_); + return; + } // TODO(crbug.com/40202416): Do something similar for MPArch. guest_->owner_rfh_id_ = new_host->GetGlobalId(); } }