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

Import map scripts should support integrity #223

Closed
guybedford opened this issue Aug 27, 2020 · 2 comments
Closed

Import map scripts should support integrity #223

guybedford opened this issue Aug 27, 2020 · 2 comments

Comments

@guybedford
Copy link
Collaborator

I just tested the following under the current Chromium implementation:

<script type="importmap" integrity="sha384-invalid">
{
  "imports": {
    "module": "./module.js"
  }
}
</script>
<script type="module">
import m from 'module';
console.log(m);
</script>

and unfortunately it appears that the integrity check on the import map script itself is not applying.

I was under the impression that the CSP compatibility discussed in #105 would have enabled this.

Is this a spec or implementation bug? Would be good to follow up further as this seems pretty important.

@domenic
Copy link
Collaborator

domenic commented Oct 6, 2020

It looks like this is working as intended. integrity="" is about fetch integrity; it modifies the fetch layer. It never works on inline scripts/styles/etc. importmap is the same as module or text/javascript in this regard.

This will work for external import maps (not implemented in Chrome at the moment), but it will not work for inline ones. This makes sense; the threat model for integrity="" is against network attackers, and there is no network involved when an inline import map is included.

It looks like there is a proposal from @mikewest to apply integrity checking to inline scripts, but it hasn't gotten multi-vendor interest, and there's a good deal of skepticism. w3c/webappsec-subresource-integrity#86.

So I don't think there's much for the import maps spec to do here.

@guybedford
Copy link
Collaborator Author

Got it, thanks for the clarification. I will go ahead and implement integrity for src importmaps in SystemJS then. Agreed the inline case isn't necessary unless progress is made elsewhere on this.

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

2 participants