#53069: fix: don't abort the process when a JS accessor throws during value conversion
Description of Change
A number of places unwrap a v8::MaybeLocal with ToLocalChecked() (or a v8::Maybe with Check() / ToChecked()) on a value that JavaScript controls. If the read runs a user accessor or Proxy trap that throws, the MaybeLocal is empty and the process aborts instead of raising a catchable error. One commit per site:
contextBridgearray copy: a renderer crash reachable from sandboxed web content by passing an array with a throwing index getter (or any nested such array) to an exposed function, or returning one from it. Spec added for both directions.contextBridgeDeepFreeze: throwing accessors on page-controlled objects reached by the freeze walk.contextBridgeinternalContextBridge.override*helpers: failed conversions wereToLocalChecked()'d.HttpResponseHeadersconverter (webRequest.onHeadersReceivedresult): throwing header getters /ownKeystraps.std::set/std::mapconverters (webRequestfilters,session.downloadURLheaders,utilityProcess.forkenv): throwing index accessors /ownKeystraps.- header-pair converter (
net.request/WebSocketheaders): throwingownKeystrap. gin_helper::Dictionary::IsEmptyObject(webContents.printoptions): throwingownKeystrap.webFrame.setSpellCheckProvider: throwinghastrap.sharedTexturenativePixmap.planes: throwing index accessor, plus a missing object check.- pooled worker contexts (
nodeIntegrationInWorker):CHECKon reading a redefinedprocess/requireglobal. - utility-process
LanguageModelbridge: malformed stream chunks / throwing getters now report an error instead ofCHECKing. Set().Check()on freshly created arrays and error objects →CreateDataProperty, so a throwing setter installed onArray.prototype/Error.prototypecannot abort.
Verified locally: each case crashes the pre-fix build with Fatal error in V8: v8::ToLocalChecked Empty MaybeLocal and surfaces as a normal JS error on the fixed build.
Checklist
- PR description included and stakeholders cc'd
-
npm testpasses - tests are changed or added
- PR title follows semantic commit guidelines
Release Notes
Notes: Fixed a renderer crash when an array with a throwing property getter is passed across contextBridge, and several main/utility-process crashes when option objects passed to Electron APIs contain throwing accessors or Proxy traps.
Backports
Semver Impact
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