Compare commits

...

1 Commits

Author SHA1 Message Date
Keeley Hammond
58d6da6b16 fix: only bind ElectronAutofillDriver on primary main frames
The `mojom::ElectronAutofillDriver` associated interface was being
registered for every `RenderFrameHost`, and `AutofillDriverFactory`
would create a driver for any live frame. In practice the native
autofill popup is only exercised from `<datalist>` / `<select>`
elements on the primary main frame — the autofill spec even notes
that `webContents.sendInputEvent` cannot route keyboard input to an
OOPIF, so subframes have no working path to this UI.

Scope the interface to where it is actually used:

* Gate the associated registry entry in
  `ElectronBrowserClient::RegisterAssociatedInterfaceBindersForRenderFrameHost`
  on `IsInPrimaryMainFrame()`, mirroring how `ElectronApiIPC` is
  already scoped in the same function.
* Return early from `AutofillDriverFactory::DriverForFrame` for any
  non-primary-main-frame RFH so the factory never stores a driver
  for an unsupported frame.
* Re-check `IsInPrimaryMainFrame()` inside
  `AutofillDriver::ShowAutofillPopup` as defense in depth for
  messages that race with a navigation.
2026-04-11 20:06:34 -07:00
3 changed files with 16 additions and 9 deletions

View File

@@ -45,6 +45,9 @@ void AutofillDriver::ShowAutofillPopup(
if (!owner_window)
return;
if (!render_frame_host_->IsInPrimaryMainFrame())
return;
// |bounds| is supplied by the renderer in the calling frame's RenderWidget
// coordinate space. Convert to the root view's space and clamp to the
// calling frame's visible viewport so a (potentially compromised) subframe

View File

@@ -61,6 +61,8 @@ void AutofillDriverFactory::DidFinishNavigation(
AutofillDriver* AutofillDriverFactory::DriverForFrame(
content::RenderFrameHost* render_frame_host) {
if (!render_frame_host->IsInPrimaryMainFrame())
return nullptr;
auto insertion_result = driver_map_.emplace(render_frame_host, nullptr);
std::unique_ptr<AutofillDriver>& driver = insertion_result.first->second;
bool insertion_happened = insertion_result.second;

View File

@@ -1541,15 +1541,17 @@ void ElectronBrowserClient::
},
&render_frame_host));
associated_registry.AddInterface<mojom::ElectronAutofillDriver>(
base::BindRepeating(
[](content::RenderFrameHost* render_frame_host,
mojo::PendingAssociatedReceiver<mojom::ElectronAutofillDriver>
receiver) {
AutofillDriverFactory::BindAutofillDriver(std::move(receiver),
render_frame_host);
},
&render_frame_host));
if (render_frame_host.IsInPrimaryMainFrame()) {
associated_registry.AddInterface<mojom::ElectronAutofillDriver>(
base::BindRepeating(
[](content::RenderFrameHost* render_frame_host,
mojo::PendingAssociatedReceiver<mojom::ElectronAutofillDriver>
receiver) {
AutofillDriverFactory::BindAutofillDriver(std::move(receiver),
render_frame_host);
},
&render_frame_host));
}
#if BUILDFLAG(ENABLE_PLUGINS)
associated_registry.AddInterface<mojom::ElectronPluginInfoHost>(
base::BindRepeating(