diff --git a/content/browser/android/nfc_host.cc b/content/browser/android/nfc_host.cc index 0000000..0000001 100644 --- a/content/browser/android/nfc_host.cc +++ b/content/browser/android/nfc_host.cc @@ -58,6 +58,13 @@ void NFCHost::GetNFC(RenderFrameHost* render_frame_host, if (render_frame_host->IsNestedWithinFencedFrame()) { mojo::ReportBadMessage("WebNFC is not allowed within in a fenced frame."); return; } + // The caller must be the *primary* main frame. Without this check a + // RenderFrameHost in the BackForwardCache (or kPendingDeletion) -- which is + // parent-less and not prerendering -- can bind NFC while a different origin + // is shown to the user. Matches content/browser/ios/nfc_host.mm. + if (web_contents()->GetPrimaryMainFrame() != render_frame_host) { + mojo::ReportBadMessage("WebNFC not on primary main frame."); + return; + } if (render_frame_host->GetBrowserContext()