Skip to content

fix: propagate requesting frame through sync permission checks - #50679

Merged
MarshallOfSound merged 1 commit into
mainfrom
sattard/permission-check-requesting-frame
Apr 4, 2026
Merged

MarshallOfSound merged 1 commit into
mainfrom
sattard/permission-check-requesting-frame

Conversation

@MarshallOfSound

@MarshallOfSound MarshallOfSound commented Apr 4, 2026 •

Copy link
Copy Markdown
Member

Description of Change

WebContentsPermissionHelper::CheckPermission hardcoded GetPrimaryMainFrame() and used web_contents_->GetLastCommittedURL(), so the two synchronous checks routed through it — Web Serial and camera/microphone — always delivered the main frame's origin to setPermissionCheckHandler, along with wrong details.isMainFrame / details.requestingUrl, even when a cross-origin subframe triggered the check.

Thread the requesting RenderFrameHost through CheckPermission and its two callers so the permission manager receives the real frame. Other paths (HID/USB/FSA, Permissions.query()) already pass the iframe frame directly and are untouched.

Checklist

  • PR description included and stakeholders cc'd
  • `npm test` passes
  • Relevant documentation changed
  • PR title follows semantic commit guidelines
  • PR release notes describe the change in a way relevant to app developers

Release Notes

Notes: no-notes

WebContentsPermissionHelper::CheckPermission was hardcoding
GetPrimaryMainFrame() and deriving the requesting origin from
web_contents_->GetLastCommittedURL(), so the setPermissionCheckHandler
callback always received the top frame's origin and
details.isMainFrame/details.requestingUrl always reflected the main
frame, even when a cross-origin subframe with allow="serial" or
allow="camera; microphone" triggered the check.

Thread the requesting RenderFrameHost through CheckPermission,
CheckSerialAccessPermission, and CheckMediaAccessPermission so the
permission manager receives the real requesting frame. Update the
serial delegate and WebContents::CheckMediaAccessPermission callers to
pass the frame they already have.

Adds a regression test that loads a cross-origin iframe with
allow="camera; microphone", calls enumerateDevices() from within the
iframe, and asserts the permission check handler receives the iframe
origin for requestingOrigin, isMainFrame, and requestingUrl.
@MarshallOfSound MarshallOfSound added semver/patch backwards-compatible bug fixes target/40-x-y PR should also be added to the "40-x-y" branch. target/41-x-y PR should also be added to the "41-x-y" branch. target/42-x-y PR should also be added to the "42-x-y" branch. labels Apr 4, 2026
@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Apr 4, 2026
@MarshallOfSound MarshallOfSound added the target/39-x-y PR should also be added to the "39-x-y" branch. label Apr 4, 2026
@MarshallOfSound
MarshallOfSound merged commit 30cf60a into main Apr 4, 2026
99 checks passed
@MarshallOfSound
MarshallOfSound deleted the sattard/permission-check-requesting-frame branch April 4, 2026 22:59
@release-clerk

release-clerk Bot commented Apr 4, 2026

Copy link
Copy Markdown

No Release Notes

@trop

trop Bot commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

I was unable to backport this PR to "39-x-y" cleanly;
you will need to perform this backport manually.

@trop trop Bot removed the target/39-x-y PR should also be added to the "39-x-y" branch. label Apr 4, 2026
@trop

trop Bot commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

I was unable to backport this PR to "40-x-y" cleanly;
you will need to perform this backport manually.

@trop

trop Bot commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "42-x-y", please check out #50686

@trop

trop Bot commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "41-x-y", please check out #50687

@trop trop Bot added in-flight/42-x-y in-flight/41-x-y and removed target/42-x-y PR should also be added to the "42-x-y" branch. target/41-x-y PR should also be added to the "41-x-y" branch. in-flight/41-x-y labels Apr 4, 2026
@trop trop Bot added merged/41-x-y PR was merged to the "41-x-y" branch. merged/42-x-y PR was merged to the "42-x-y" branch. and removed in-flight/42-x-y labels Apr 5, 2026
MarshallOfSound added a commit that referenced this pull request Apr 6, 2026
WebContentsPermissionHelper::CheckPermission was hardcoding
GetPrimaryMainFrame() and deriving the requesting origin from
web_contents_->GetLastCommittedURL(), so the setPermissionCheckHandler
callback always received the top frame's origin and
details.isMainFrame/details.requestingUrl always reflected the main
frame, even when a cross-origin subframe with allow="serial" or
allow="camera; microphone" triggered the check.

Thread the requesting RenderFrameHost through CheckPermission,
CheckSerialAccessPermission, and CheckMediaAccessPermission so the
permission manager receives the real requesting frame. Update the
serial delegate and WebContents::CheckMediaAccessPermission callers to
pass the frame they already have.

Adds a regression test that loads a cross-origin iframe with
allow="camera; microphone", calls enumerateDevices() from within the
iframe, and asserts the permission check handler receives the iframe
origin for requestingOrigin, isMainFrame, and requestingUrl.
@trop

trop Bot commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

@MarshallOfSound has manually backported this PR to "39-x-y", please check out #50714

MarshallOfSound added a commit that referenced this pull request Apr 6, 2026
WebContentsPermissionHelper::CheckPermission was hardcoding
GetPrimaryMainFrame() and deriving the requesting origin from
web_contents_->GetLastCommittedURL(), so the setPermissionCheckHandler
callback always received the top frame's origin and
details.isMainFrame/details.requestingUrl always reflected the main
frame, even when a cross-origin subframe with allow="serial" or
allow="camera; microphone" triggered the check.

Thread the requesting RenderFrameHost through CheckPermission,
CheckSerialAccessPermission, and CheckMediaAccessPermission so the
permission manager receives the real requesting frame. Update the
serial delegate and WebContents::CheckMediaAccessPermission callers to
pass the frame they already have.

Adds a regression test that loads a cross-origin iframe with
allow="camera; microphone", calls enumerateDevices() from within the
iframe, and asserts the permission check handler receives the iframe
origin for requestingOrigin, isMainFrame, and requestingUrl.
@trop

trop Bot commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

@MarshallOfSound has manually backported this PR to "40-x-y", please check out #50719

jkleinsc pushed a commit that referenced this pull request Apr 6, 2026
fix: propagate requesting frame through sync permission checks (#50679)

WebContentsPermissionHelper::CheckPermission was hardcoding
GetPrimaryMainFrame() and deriving the requesting origin from
web_contents_->GetLastCommittedURL(), so the setPermissionCheckHandler
callback always received the top frame's origin and
details.isMainFrame/details.requestingUrl always reflected the main
frame, even when a cross-origin subframe with allow="serial" or
allow="camera; microphone" triggered the check.

Thread the requesting RenderFrameHost through CheckPermission,
CheckSerialAccessPermission, and CheckMediaAccessPermission so the
permission manager receives the real requesting frame. Update the
serial delegate and WebContents::CheckMediaAccessPermission callers to
pass the frame they already have.

Adds a regression test that loads a cross-origin iframe with
allow="camera; microphone", calls enumerateDevices() from within the
iframe, and asserts the permission check handler receives the iframe
origin for requestingOrigin, isMainFrame, and requestingUrl.
@trop trop Bot added merged/39-x-y PR was merged to the "39-x-y" branch. and removed in-flight/39-x-y labels Apr 6, 2026
jkleinsc pushed a commit that referenced this pull request Apr 6, 2026
fix: propagate requesting frame through sync permission checks (#50679)

WebContentsPermissionHelper::CheckPermission was hardcoding
GetPrimaryMainFrame() and deriving the requesting origin from
web_contents_->GetLastCommittedURL(), so the setPermissionCheckHandler
callback always received the top frame's origin and
details.isMainFrame/details.requestingUrl always reflected the main
frame, even when a cross-origin subframe with allow="serial" or
allow="camera; microphone" triggered the check.

Thread the requesting RenderFrameHost through CheckPermission,
CheckSerialAccessPermission, and CheckMediaAccessPermission so the
permission manager receives the real requesting frame. Update the
serial delegate and WebContents::CheckMediaAccessPermission callers to
pass the frame they already have.

Adds a regression test that loads a cross-origin iframe with
allow="camera; microphone", calls enumerateDevices() from within the
iframe, and asserts the permission check handler receives the iframe
origin for requestingOrigin, isMainFrame, and requestingUrl.
@trop trop Bot added merged/40-x-y PR was merged to the "40-x-y" branch. and removed in-flight/40-x-y labels Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged/39-x-y PR was merged to the "39-x-y" branch. merged/40-x-y PR was merged to the "40-x-y" branch. merged/41-x-y PR was merged to the "41-x-y" branch. merged/42-x-y PR was merged to the "42-x-y" branch. new-pr 🌱 PR opened recently semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants