Add iframe attributes for allow and sandbox configurations before ins… - #395
Open
Albert LI (albertli-msft) wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two upstream PRs, in this order. The
powerbi-modelschange must ship and beconsumed before the
PowerBI-JavaScriptchange will typecheck.PR 1 of 2 —
microsoft/powerbi-modelsTitle: Add
iframeAllow/iframeSandboxtoIBootstrapEmbedConfigurationWhat
Two optional string fields on
IBootstrapEmbedConfiguration, inherited by everyembed configuration type:
Why
powerbi-clientcreates the embed iframe internally, setssrc, and appends it tothe container. Consumers therefore have no opportunity to put an
alloworsandboxattribute on the element before it is inserted.That matters because Chromium snapshots both the sandbox flags and the
permissions-policy container when the frame is inserted. Setting either
attribute after
powerbi.embed()returns updates the DOM but has no effect on thedocument that loads. Consumers doing this today are silently getting neither the
delegation nor the sandboxing they think they configured.
These fields give
powerbi-clienta supported way to receive the values in time.See PR 2 for the consuming change and the real-world failure that motivated it.
Notes
MultipleFieldsValidatoronly validates fields it isgiven, so unknown properties are ignored rather than rejected.
PR 2 of 2 —
microsoft/PowerBI-JavaScriptTitle: Apply iframe
allow/sandboxbefore inserting the frameWhat
In
Embed.setIframe, beforeappendChild:Why
Chromium 142 shipped Local Network Access. A request from a
publicorigin to anRFC1918 address is now gated behind a permission that is a policy-controlled feature
with a default allowlist of
'self'. Under Workspace-level Private Link, Fabricbackend hostnames resolve through the
privatelink.*zone to a Private Endpoint IPin
10.0.0.0/8, so ordinary backend calls from an embed iframe are reclassified aslocal network requests and blocked:
(The message arrives on the CORS channel but is not a CORS problem.)
The host must delegate the feature with
<iframe allow="local-network-access">.Consumers can only do that after
powerbi.embed()returns, by which point theframe is already inserted and its policy container already snapshotted. The
attribute is then plainly visible in DevTools while having had no effect — which is
what makes this so hard to diagnose.
Evidence (live Private Link repro, Edge 151):
allowattribute present on the iframe in the DOMallowsFeature('local-network-access')in the parent frametrueallowsFeature('local-network-access')in the embed framefalseiframe.src = iframe.srcallowsFeature→true, and the backend call succeedsRe-navigation re-snapshots the container policy from the now-present attribute,
confirming both the mechanism and the fix.
Impact
Not specific to any one embed type — report, dashboard, tile, qna and datahub embed
all share this code path and all have the same Private Link exposure. It also
restores
sandboxfor consumers who set it post-embed and are currently notsandboxed at all.
Risk
No behavior change when the fields are unset; both branches are guarded.
Dependencies / open items
powerbi-modelsversion from PR 1.iframeAllow/iframeSandboxwill be included in the/report/loadpostMessagepayload, since
Embed.load()posts the whole config. Harmless, but happy to stripthem if reviewers prefer.
Follow-up (not yet written) —
PowerBI-JavaScript-DatahubOnce the above ship,
setIframeAttributescan be deleted outright:Port the same change to the PowerBIClients mirror at
trident/libs/datahub-client-test/src/embed.ts. Note thatembed-e2edoes not callembed(), so it will not cover any of this.References