MarshallOfSound

#53258: fix: use-after-free when event handlers re-enter chooser, protocol stream, webauthn and local AI code

Merged
Created: Aug 28, 2026, 2:18:52 AM
Merged: Aug 28, 2026, 4:58:33 AM
4 comments
Target: main

Description of Change

Fixes six re-entrancy bugs with the same shape: native code emits an event or calls user JS while still holding this or a live iterator, and the handler (legitimately) destroys the owner or mutates the container. All are use-after-free / iterator-invalidation crashes; per-site detail is in each commit.

  • select-bluetooth-device callback invoked synchronously — weak-self check after emit in BluetoothChooser.
  • select-hid-device / hid-device-removed handler destroys the requesting webContents — weak-self check in HidChooserController.
  • Custom protocol stream whose on() / removeListener() fires listeners synchronously — weak-self checks in NodeStreamLoader::Start, invalidate weak ptrs first in the destructor.
  • select-webauthn-account / -authenticator listener calls back then throws — weak-self check after emit.
  • Cancelling pending local-AI create() / append() — erase the AbortController map entry before calling abort() instead of holding the iterator across it.
  • isolated-world-created listener that registers more listeners — iterate a copy of the callback vector.

Regression specs added for all except Bluetooth (needs a real adapter).

Checklist

Release Notes

Notes: Fixed crashes when certain app event handlers call back into Electron synchronously.

Backports

43-x-y
Pending
Waiting for a manual backport
44-x-y
Pending
Waiting for a manual backport
45-x-y
In-flight
PR Number
#53269
Waiting to be merged

Semver Impact

Major
Breaking changes
Minor
New features
Patch
Bug fixes
None
Docs, tests, etc.

Semantic Versioning helps users understand the impact of updates:

  • Major (X.y.z): Breaking changes that may require code modifications
  • Minor (x.Y.z): New features that maintain backward compatibility
  • Patch (x.y.Z): Bug fixes that don't change the API
  • None: Changes that don't affect using facing parts of Electron