Research 16 min read Sep 7, 2026 6

The Top-Level Origin Is Not the Requesting Principal: Testing Permission Delegation Across Frames

A trusted top-level origin does not establish the authority of an embedded frame. We examine permission delegation when the requester and the identity checked by the handler differ.

BrowserSecurity ApplicationSecurity PermissionsPolicy IframeSecurity IdentitySecurity AutonomousPentesting
S
SecureHup Team
Security Researcher · SecureHup
The Top-Level Origin Is Not the Requesting Principal: Testing Permission Delegation Across Frames

A trusted desktop application embeds a cross-origin support widget and delegates microphone use. The child frame requests access, but the permission handler checks the top-level application's origin. The prompt and audit record show the trusted parent; the capability is delivered to code from another origin.

A recent desktop-runtime vulnerability exposed this mismatch only under specific conditions: origin-based handler logic, cross-origin embedding, and delegated device permissions. Those prerequisites bound the affected applications. The transferable lesson is that delegation allows a child to request a capability; it does not merge the child's identity with the parent.

The grant must bind requesting document, current security origin, top-level application, feature, target resource, user gesture, and document lifetime. Navigation, frame replacement, and process reuse can change that tuple after an earlier decision, so lifecycle belongs in both design and testing.

Key Takeaways

  • The top-level origin identifies the application container; it does not identify a cross-origin frame that initiates a permission request.
  • Permissions Policy can determine whether a child may use a feature, but application-level permission handlers must still authorize the actual requesting frame and resource.
  • Permission grants should bind requester origin, frame/document identity, feature, resource scope, user intent, and lifetime.
  • Navigation, frame replacement, redirects, popups, workers, and stored permission state can invalidate an earlier decision.
  • Reliable testing uses controlled origins, virtual devices, frame-level telemetry, and effect assertions across allowed and denied combinations.
  • Patching the runtime is necessary, while application defense should also prefer authoritative security-origin fields and deny unexpected embedded principals.

A Page Contains More Than One Principal

Modern applications compose content from several security origins. A trusted top-level document may contain payment widgets, support panels, media components, analytics, previews, user-generated applications, or partner integrations. Each cross-origin frame runs under a distinct web principal even though the user sees one window.

The security-relevant graph can look like this:

top-level application: https://app.example
  -> same-origin navigation frame
  -> trusted media frame: https://media.example
  -> partner frame: https://partner.example
  -> user-content frame: https://tenant-content.example

A permission prompt may be presented in the context of the top-level application because that is what the user recognizes. The code receiving the capability can still be a child frame. User-interface attribution and requesting principal are related but not interchangeable.

Container Trust and Requester Trust Are Separate

The parent controls whether a feature is delegable to a child through embedding policy. That decision means, at most, "this frame may participate in the permission flow." It does not necessarily mean:

  • The child is trusted for every device.
  • The child can retain access after navigation.
  • A nested descendant is also trusted.
  • The child may use the feature without user intent.
  • The child may transfer handles or data elsewhere.
  • The application permission handler can skip origin checks.

Delegation opens a gate. Authorization still decides who walks through it and with what scope.

Build the Permission Decision Tuple

An origin-only allowlist can be too broad even when it uses the correct requester. The full decision contains more context:

PermissionDecision = {
  top_level_origin,
  requesting_origin,
  requesting_document_id,
  frame_tree_position,
  feature,
  resource_scope,
  user_gesture_id,
  application_context,
  policy_version,
  issued_at,
  expires_at
}

Different platforms expose different fields. The most authoritative requester security context is the one supplied by the runtime, not a URL string from the page, a referrer, or the main frame.

Why Document Identity Matters

An origin can remain the same while a document changes. A frame may navigate, reload, be replaced, or enter the back-forward cache. A permission granted to one document instance should not automatically attach to a later document unless product policy explicitly grants persistent origin-level access.

For sensitive transient capabilities, bind the grant to a document or frame lifecycle token and revoke it on navigation, detachment, origin change, session end, or loss of the relevant user context.

Why Resource Scope Matters

“Camera access” may mean one selected device for one call, all cameras until the app closes, or permanent access for the origin. Serial and USB permissions can identify specific devices. Screen capture can identify a selected surface. File access can identify a handle. The stored grant should retain the narrow resource the user selected rather than only a generic feature flag.

Permissions Policy Is Necessary but Not Sufficient

Permissions Policy lets a top-level site restrict whether documents may use selected browser features and delegate them to specific frames or origins. This is a powerful containment layer, especially because many capabilities are disabled by default in cross-origin frames unless delegated.

However, several decisions remain:

Layer Decision Failure if confused
Embedder policy May this frame be eligible for the feature? Feature delegated too broadly
Runtime permission handler Which requesting principal is asking? Main-frame identity masks child
User consent Does the user approve this purpose/resource now? Silent or misleading access
Application authorization Is this tenant, role, and workflow allowed? Valid origin crosses business boundary
Device/resource broker Which concrete resource may be used? Grant expands to unrelated devices
Lifecycle manager When should access end? Permission survives navigation or task

Passing one layer does not imply passing the others. The runtime should provide accurate request context, and the application should verify it rather than assuming delegation settled identity.

Keep Allowlists Narrow

Broad wildcards are difficult to reconcile with embedded origins that carry different trust. Exact HTTPS origins and explicit feature directives make eligibility narrower, while redirect review accounts for a final frame origin that differs from the initial src. Where tenant or user content lives on subdomains, a wildcard can otherwise give every tenant the same powerful feature eligibility.

The iframe allow attribute and response policy behave like code: they change capability eligibility and belong under version control, review, and testing alongside permission-handler changes.

Common Principal-Binding Failures

Using the Main Frame by Convenience

Application APIs often expose several origin fields: main-frame URL, requesting origin, security origin, embedding origin, or frame details. Developers may choose the most familiar one. Name ambiguity is dangerous, so confirm semantics in the current runtime documentation and verify with a multi-origin test.

Trusting Frame URLs Instead of Security Origins

A visible URL string may be stale, redirected, inherited, opaque, or not the authoritative security principal. The runtime's security-origin representation carries stronger provenance, while opaque origins generally call for conservative handling. Ad hoc string prefixes cannot reproduce those semantics reliably.

Caching by Feature Alone

A cache entry such as camera: allowed can apply one frame's decision to every frame. Cache keys should include the security dimensions that define interchangeability, and the cached value should be bound to the requester and resource.

Reusing Consent After Navigation

A frame can request permission, navigate to another origin, and continue using a handle or reused grant if lifecycle binding is weak. Revalidate or revoke on navigation and frame replacement.

Confusing Parent Approval with Child Authority

The parent may send a message asking a child to start capture. Message origin, frame identity, current document, and requested resource still require validation. A generic postMessage listener that accepts any origin can bypass an otherwise correct permission handler.

Applying Different Rules to Different Device APIs

Camera and microphone may use one handler while serial, USB, Bluetooth, geolocation, notifications, or screen capture use another. An inventory prevents one correct callback from being mistaken for coverage of every powerful feature.

Design a Safer Permission Broker

Centralize powerful feature decisions in a small component instead of scattering callbacks across windows and plugins.

Normalize Authoritative Context

The broker receives runtime-provided details and constructs an immutable request object. It rejects missing, opaque, malformed, insecure, or unexpected origins according to policy. The web content cannot submit its own trusted origin field.

Evaluate Policy in a Predictable Order

runtime request
  -> verify active frame/document
  -> resolve authoritative requesting origin
  -> verify embedder delegation
  -> verify application tenant/role/workflow
  -> require recent user intent when applicable
  -> constrain concrete resource
  -> issue short-lived grant
  -> audit and monitor use

Fail closed when required context is unavailable. A runtime regression that omits requester identity should cause denial, not fallback to the top-level origin.

Make User Consent Legible

Where the platform exposes a user prompt, the application should identify the embedded component and requested capability accurately. A prompt is misleading when a trusted brand appears to request access while an unrelated frame receives it. High-risk integrations may benefit from a user-initiated first-party step followed by a narrow capability issued to the expected child document.

Revoke Aggressively

Revoke on frame navigation, detachment, origin change, top-level logout, tenant switch, permission-policy change, resource disconnect, or task completion. Persistent grants should be an explicit product decision with a management UI and audit record, not a side effect of callback caching.

Test with Controlled Origins and Virtual Resources

Permission testing can be deterministic and private through local test origins with valid certificates or runtime-supported secure contexts, paired with virtual devices or mocked brokers.

A Minimal Origin Fixture

  • app.test: trusted top-level application.
  • media.test: explicitly allowed child.
  • partner.test: embedded but not allowed for the feature.
  • other.test: untrusted child and redirect destination.
  • Nested child under media.test with a separate origin.

Serve distinct frame labels and record document IDs, origins, navigation events, and permission requests. The protected effect should be access to a synthetic device or a local broker token, never a real camera feed, microphone, or hardware device.

Permission Matrix

Top-level Requesting frame Delegated? App policy Expected effect
Trusted Same origin Yes/default Allowed Synthetic resource granted
Trusted Approved cross-origin Yes Allowed Narrow grant to child document
Trusted Approved cross-origin No Allowed Denied by embedder policy
Trusted Unapproved cross-origin Yes by mistake Denied No broker capability issued
Trusted Nested unapproved origin Parent delegated Denied Parent identity cannot mask descendant
Trusted Child navigates after grant Previously allowed Reevaluate Old grant revoked
Untrusted top-level Approved child Any Denied No grant based only on child name

Assert More Than Callback Arguments

The evidence should show which frame receives the media stream or device handle, which document uses it, whether a virtual resource was opened, whether an indicator appears, and whether access ends on navigation. A callback can receive the expected string while another defect delivers the handle to the wrong frame.

Test Concurrency and Ordering

Have two frames request the same feature simultaneously. Confirm that approval, resource selection, callback, and audit event remain bound to the correct frame. Test a frame navigation while a prompt is open. The completed decision should be rejected if the document changed during consent.

Lifecycle Test Cases Teams Often Miss

  • Child redirects before requesting permission.
  • Child redirects while a request is pending.
  • Frame is removed and recreated with the same name.
  • Same-origin child navigates cross-origin after a grant.
  • Cross-origin child navigates to an opaque or local document.
  • Top-level page changes tenant without full reload.
  • Application window is restored from session state.
  • Permission handler is registered late or throws an exception.
  • Multiple windows share a session object or permission cache.
  • A service worker or background page continues after the visible frame closes.
  • A child transfers a resource handle through messaging.
  • A plugin creates an iframe outside the main component tree.

Each case should have an effect-level oracle and a clear revocation expectation.

Patch the Runtime and Harden the Application

When a runtime supplies the wrong requesting origin, application code cannot reliably reconstruct every security detail. Upgrade to a fixed, supported version. If the advisory offers an authoritative alternate field as a temporary workaround, use it exactly as documented and test the affected permissions.

Then harden the application:

  • Deny permission when authoritative requester context is missing.
  • Use the requesting frame's security origin, not the main frame URL.
  • Keep exact allowlists by feature.
  • Avoid delegating powerful features to untrusted frames.
  • Bind grants to document and resource lifetime.
  • Centralize callbacks and policy.
  • Audit actor, frame, origin, feature, resource, and decision.
  • Revoke stored grants that may have been issued under incorrect context.
  • Review whether affected versions were deployed with the required iframe architecture.

Runtime version alone does not establish exposure. The application also has to use the relevant origin-based handler logic, cross-origin frames, and delegated permissions.

Continuous Validation Across Code and Browser State

Permission bugs often emerge from interactions between application code, runtime APIs, iframe attributes, response headers, navigation, and cached state. Static analysis can identify which origin field a handler uses and which features are delegated. A headless multi-origin test can then prove which frame receives the synthetic capability.

A useful workflow is:

permission or embedding diff
  -> inventory changed handlers, frame origins, and policies
  -> generate allowed and denied frame scenarios
  -> launch isolated application with virtual devices
  -> coordinate navigation and concurrent requests
  -> observe grant recipient and protected effect
  -> preserve principal-binding trace
  -> replay on runtime and application upgrades

SecureHup's headless browser, multi-persona testing, and code/runtime correlation are relevant here because the user value is proof across layers. A finding can show not only that code reads a questionable origin field, but that a specific denied child frame receives a synthetic protected capability. The same proof can guard later changes to permission callbacks, iframe policy, and runtime versions.

Follow the Capability After It Is Granted

The permission callback is not always the final boundary. A trusted frame can receive a device stream, file handle, port, or broker token and then transfer access through a message channel. Paths that move permission-derived data or control between frames, windows, workers, and native bridges extend the review surface.

Message handlers should verify the exact sender origin and, where the platform supports it, the expected source window or frame identity. Structured message types and field validation preserve that context, while * is an unsuitable target origin for sensitive replies. A child message named ready or start is not enough to justify forwarding a capability; the request still needs a relationship to the authorized document, user action, feature, and resource.

Test confused-deputy scenarios with at least three principals. An allowed child asks the parent to open the synthetic resource, an unapproved sibling sends an equivalent message, and a nested descendant attempts to relay through the allowed child. Verify that only the exact approved requester receives usable access and that identifiers cannot be replayed by another frame. Navigate the allowed child after the handle is issued and confirm the old document cannot continue through a retained message port.

Also inspect native or preload bridges in desktop applications. A browser permission may be correct while a bridge method exposes the same device operation without equivalent origin or frame checks. Enumerate all paths to the protected effect and apply one authorization model at the broker. A permission test is complete only when no alternate adapter can produce the same capability for a denied principal.

Minimize Privacy Exposure During Decision Making

Permission checks can leak information even when they deny access. Detailed device inventories, stable hardware identifiers, or distinct errors for unapproved frames can support fingerprinting. Resolving only what the decision needs and revealing resource details after authorization and consent keeps denial behavior less informative where product requirements permit.

Audit records should identify the normalized resource category and internal resource reference without storing media content or unnecessary hardware detail. Synthetic test resources make this easier: they prove recipient binding and revocation without collecting a real user's camera, microphone, screen, or connected-device data.

Release Checklist

  • Runtime versions meet the fixed-version guidance for every maintained release line.
  • All application windows, sessions, and embedded frame trees are inventoried.
  • Permission handlers use authoritative requesting security context.
  • Missing or opaque requester context fails closed.
  • Permissions Policy and iframe attributes use exact required origins.
  • Application role, tenant, and workflow checks remain independent of origin.
  • Grants bind feature, resource, frame/document, and lifetime.
  • Pending requests are invalidated by navigation or frame replacement.
  • Concurrent requests cannot swap callbacks or selected resources.
  • Direct, nested, redirected, restored, and plugin-created frames are tested.
  • Virtual-resource tests assert the recipient, not only the decision value.
  • Audit records distinguish top-level app, requesting frame, user, and executor.

Retain One Navigation Regression

A browser regression in which the delegated child receives permission, navigates to another controlled origin, and asks again captures an important lifecycle property. The original grant should not follow the new document merely because the top-level window stayed unchanged. Ordinary same-page tests rarely exercise that identity-and-lifetime binding.

FAQ

What is the difference between the top-level origin and requesting origin?

The top-level origin belongs to the main document the user sees. The requesting origin belongs to the document or frame that actually called the powerful API. They can be different when the page embeds cross-origin iframes. A permission decision should use authoritative context for the requesting frame while also considering the trusted top-level container and delegation policy.

Does the iframe allow attribute authorize device access?

It makes selected features eligible for the frame under Permissions Policy. It does not replace runtime permission checks, user consent, application authorization, device selection, or lifecycle controls. It is one gate in a layered decision rather than a complete grant.

Are applications affected if they do not use cross-origin iframes?

The specific vulnerability that motivated this analysis required an origin-based permission handler and cross-origin frames with delegated relevant permissions. Applications without those conditions were not affected by that exact path. They should still test principal binding because future embedding, plugins, or other permission APIs can introduce similar mistakes.

How can permission flows be tested without using real devices?

Runtime-supported virtual media devices, mocked hardware brokers, synthetic handles, and controlled origins provide enough evidence in an isolated environment. External communication can remain blocked while frame, navigation, permission, and effect telemetry identifies the recipient. Real user hardware and data are unnecessary.

When should a frame permission be revoked?

At minimum, reevaluate or revoke on frame navigation, origin change, detachment, replacement, top-level logout, tenant change, policy update, resource disconnect, and completion of the user-intended task. Persistent origin grants should be explicit, visible, narrowly scoped, and manageable by the user.

Permission Belongs to the Requesting Document

Authoritative requester context lets a grant remain associated with the origin, document instance, feature, virtual resource, and user gesture that produced it. Navigation, frame replacement, origin change, and lifecycle termination can invalidate that association even while the trusted top-level application remains open.

A controlled frame tree with distinct origins and virtual devices makes these transitions visible without touching real hardware. Swapped children, post-approval navigation, and sibling requests should all leave evidence about the principal that actually received the capability. The host window provides context, but it is not a substitute for the identity of the requesting document.

#BrowserSecurity #ApplicationSecurity #PermissionsPolicy #IframeSecurity #IdentitySecurity #AutonomousPentesting

Was this helpful?
Share :

Find issues like this in your own codebase

SecureHup runs this exact exploit chain — discovery, enumeration and cross-tenant validation — on every deployment, automatically.