Skip to content

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

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

fix: prevent use-after-free in permission request callbacks#50035
jkleinsc merged 1 commit into
39-x-yfrom
trop/39-x-y-bp-fix-prevent-use-after-free-in-permission-request-callbacks-1772496093507

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 39-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes labels Mar 3, 2026
@jkleinsc jkleinsc merged commit 69c8cbf into 39-x-y Mar 3, 2026
157 of 159 checks passed
@jkleinsc jkleinsc deleted the trop/39-x-y-bp-fix-prevent-use-after-free-in-permission-request-callbacks-1772496093507 branch March 3, 2026 14:13
@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

39-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.

2 participants