Skip to content

fix: prevent use-after-free in permission request callbacks#50036

Merged
dsanders11 merged 1 commit into
40-x-yfrom
trop/40-x-y-bp-fix-prevent-use-after-free-in-permission-request-callbacks-1772496094921
Mar 3, 2026
Merged

fix: prevent use-after-free in permission request callbacks#50036
dsanders11 merged 1 commit into
40-x-yfrom
trop/40-x-y-bp-fix-prevent-use-after-free-in-permission-request-callbacks-1772496094921

Conversation

@trop

@trop trop Bot commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

Backport of #50032

See that PR for details.

Notes: none

EnterFullscreenModeForTab, RequestPointerLock, and RequestKeyboardLock
bind callbacks with base::Unretained(this); fullscreen also captures a
raw RenderFrameHost*. These callbacks may be invoked by the app's JS
permission handler after the WebContents or RenderFrameHost is destroyed.

Use GetWeakPtr() in all three call sites, and capture a
GlobalRenderFrameHostToken instead of the raw RenderFrameHost* for
fullscreen so the pointer is resolved and null-checked only when the
callback fires. Cancel in-flight permission requests from ~WebContents()
via a new ElectronPermissionManager::CancelPendingRequests()` so stale
callbacks are never handed back to JS.

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
@trop trop Bot requested review from a team and codebytere March 3, 2026 00:01
@trop trop Bot added 40-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes labels Mar 3, 2026
@dsanders11 dsanders11 merged commit d80adf4 into 40-x-y Mar 3, 2026
67 checks passed
@dsanders11 dsanders11 deleted the trop/40-x-y-bp-fix-prevent-use-after-free-in-permission-request-callbacks-1772496094921 branch March 3, 2026 04:44
@release-clerk

release-clerk Bot commented Mar 3, 2026

Copy link
Copy Markdown

No Release Notes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

40-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant