Skip to content

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

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

fix: prevent use-after-free in permission request callbacks#50034
dsanders11 merged 1 commit into
41-x-yfrom
trop/41-x-y-bp-fix-prevent-use-after-free-in-permission-request-callbacks-1772496092838

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 41-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes labels Mar 3, 2026
@dsanders11 dsanders11 merged commit fcaf525 into 41-x-y Mar 3, 2026
67 checks passed
@release-clerk

release-clerk Bot commented Mar 3, 2026

Copy link
Copy Markdown

No Release Notes

@dsanders11 dsanders11 deleted the trop/41-x-y-bp-fix-prevent-use-after-free-in-permission-request-callbacks-1772496092838 branch March 3, 2026 04:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

41-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