Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace references to the "sync-xhr" policy-controlled feature #419

Open
sideshowbarker opened this issue Mar 26, 2021 · 0 comments
Open

Comments

@sideshowbarker
Copy link
Contributor

whatwg/xhr#322 drops the sync-xhr policy-controlled feature from XHR.

There are two references to the sync-xhr feature that should therefore be be replaced in the Permissions Policy spec:

new_frame.allow = 'sync-xhr';
// This will be true, as the iframe is allowed to use sync-xhr at whatever URL is
// mentioned in its src attribute, even though that attribute is not yet set.
const is_sync_xhr_allowed = new_frame.permissionsPolicy.allowsFeature('sync-xhr');

<div class="example">
<p>As a practical (though contrived) example, consider a document which uses
synchronous XMLHttpRequest to determine whether a user has sufficient
privileges to access the page:</p>
<pre>
&lt;!DOCTYPE html&gt;
&lt;h1&gt;Welcome to SecureCorp!&lt;/h1&gt;
&lt;script&gt;
var req = new XMLHttpRequest();
req.open("GET", "/api/security_check.json", false);
req.send();
if (req.response == "untrusted user") {
// User is not logged in; redirect to a safe page
location.href = "/security_check_failed.html";
}
&lt;/script&gt;
&lt;!-- Page continues with assumption that user is logged in --&gt;
</pre>
<p>If this document is embedded by a page which disables the
"<code>sync-xhr</code>" feature, the call to `XMLHttpRequest.open()` would
fail, and the security check would be bypassed.</p>
</div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant