Skip to content

fix: use requesting frame origin in permission helper and device choosers#50149

Merged
ckerr merged 2 commits into40-x-yfrom
trop/40-x-y-bp-fix-use-requesting-frame-origin-in-permission-helper-and-device-choosers-1773073233302
Mar 10, 2026
Merged

fix: use requesting frame origin in permission helper and device choosers#50149
ckerr merged 2 commits into40-x-yfrom
trop/40-x-y-bp-fix-use-requesting-frame-origin-in-permission-helper-and-device-choosers-1773073233302

Conversation

@trop
Copy link
Copy Markdown
Contributor

@trop trop bot commented Mar 9, 2026

Backport of #50052

See that PR for details.

Notes: Fixed an issue where permission and device-chooser handlers received the top-level page origin instead of the requesting subframe's origin.

trop bot and others added 2 commits March 9, 2026 16:20
…ions

`WebContentsPermissionHelper::RequestPermission` passes
`web_contents_->GetLastCommittedURL()` as the origin to the permission
manager instead of the actual requesting frame's origin. This enables
origin confusion when granting permissions to embedded third-party iframes,
since app permission handlers see the top-level origin instead of the
iframe's. The same pattern exists in the HID, USB, and Serial device
choosers, where grants are keyed to the primary main frame's origin rather
than the requesting frame's.

Fix this by using `requesting_frame->GetLastCommittedOrigin()` in all
affected code paths, renaming `details.requestingUrl` to
`details.requestingOrigin`, and populating it with the serialized
origin only.

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
The previous commit changed the details.requestingUrl field to
details.requestingOrigin in permission request/check handlers. That
field was already populated from the requesting frame's RFH, so the
rename was unnecessary and would break apps that read the existing
property. Revert to requestingUrl to preserve the existing API shape.

The functional changes to use the requesting frame in
WebContentsPermissionHelper and the HID/USB/Serial choosers remain.

Co-authored-by: Samuel Attard <sattard@anthropic.com>
@trop trop bot requested review from a team and codebytere March 9, 2026 16:21
@trop trop bot added 40-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes labels Mar 9, 2026
@ckerr ckerr merged commit 4fe6271 into 40-x-y Mar 10, 2026
107 of 110 checks passed
@ckerr ckerr deleted the trop/40-x-y-bp-fix-use-requesting-frame-origin-in-permission-helper-and-device-choosers-1773073233302 branch March 10, 2026 04:03
@release-clerk
Copy link
Copy Markdown

release-clerk bot commented Mar 10, 2026

Release Notes Persisted

Fixed an issue where permission and device-chooser handlers received the top-level page origin instead of the requesting subframe's origin.

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.

2 participants