Skip to content

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

Merged
ckerr merged 1 commit into
38-x-yfrom
mb-38-use-after-free-permission
Mar 9, 2026
Merged

fix: prevent use-after-free in permission request callbacks#50153
ckerr merged 1 commit into
38-x-yfrom
mb-38-use-after-free-permission

Conversation

@VerteDinde

Copy link
Copy Markdown
Member

Manual 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.
@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Mar 9, 2026
@trop trop Bot requested a review from a team March 9, 2026 16:47
@trop trop Bot added 38-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes labels Mar 9, 2026
@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Mar 9, 2026
@ckerr ckerr merged commit 07a1e9c into 38-x-y Mar 9, 2026
114 of 115 checks passed
@ckerr ckerr deleted the mb-38-use-after-free-permission branch March 9, 2026 22:20
@release-clerk

release-clerk Bot commented Mar 9, 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

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

3 participants