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

[Security] Declarative network permissions in parent scope for safe request default mode #1209

Closed
ghost opened this issue Apr 6, 2021 · 2 comments

Comments

@ghost
Copy link

ghost commented Apr 6, 2021

Context:

The default mode of a request is "no-cors", meaning that, by default, the fetch API is unsafe to use, as pointed out in the specification. The Fetch API is also available by default in script tags, so that a tampered script loaded from a remote third-party CDN can gain full network access within the context of the document or application.

Background:

In (whatwg/html#6553), was introduced a declarative way for web developers to easily reason about network permissions without having to deal with HTTP headers, via the allow-net attribute in insecure HTML tags. This declarative approach for defining network policies would be more in line with the HTML specification than current network policies approaches, while offering:

Proposal:

The Fetch API can be made safe by default by using declarative network permissions in the parent scope, via the allow-net attribute in insecure HTML tags.

Example:

<script allow-net="https://example.com">
/* Script has only access to https://example.com */

/* Following fetch will fail */
fetch('https://anothersite.com/data.json')
  .then(response => response.json())
  .then(data => console.log(data));

/* Following fetch will likely succeed */
fetch('https://example.com/data.json')
  .then(response => response.json())
  .then(data => console.log(data));

</script>

<script >
/* Script does not have network access */

/* Following fetch will fail */
fetch('https://example.com/data.json')
  .then(response => response.json())
  .then(data => console.log(data));

</script>

Those declarative permissions could be set at the level of the whole document in the head tag, and/or in a fine-grained way within insecure HTML tags such as iframe, portal, script, etc., that is, everywhere the Fetch API can be used.

@yutakahirano
Copy link
Member

cc: @mikewest
Isn't this a proposal to CSP or HTML?

@domenic
Copy link
Member

domenic commented Apr 6, 2021

Hi @abflow,

Thanks for your interest in improving the web, and all your many (many) issues proposing novel security mechanisms and models.

However, I think the WHATWG is probably not the best place to pursue those issues, given the lack of interest so far. I'd suggest incubating them in another community, such as https://discourse.wicg.io/. Once you have at least one implementer interested and prototyping your ideas in browser code, we can open issues on WHATWG repositories with specific technical changes.

Until that time, we'd kindly ask that you refrain from opening new issues of this sort. And especially that you stop commenting on existing issues that refer to similar keywords, pointing people to your proposals.

I'll close this and similar issues you've been opening across the WHATWG ecosystem, but I encourage you to take such new proposals to an incubation community such as the aforementioned https://discourse.wicg.io/.

Thanks for understanding,
-Domenic

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

No branches or pull requests

2 participants