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

Should WebAssembly modules be explicitly marked? #19

Open
littledan opened this issue Nov 8, 2019 · 15 comments
Open

Should WebAssembly modules be explicitly marked? #19

littledan opened this issue Nov 8, 2019 · 15 comments

Comments

@littledan
Copy link
Member

Various opinions are given in WICG/webcomponents#839. On one hand, Wasm is somehow equivalently powerful to JS, suggesting that the security needs are less stark. On the other hand, they have different parsers, so ambiguity may still be damaging. I don't think we need a final resolution within this proposal on this question, but this blocks WebAssembly/ESM integration. Cc @rniwa @annevk

@annevk
Copy link
Member

annevk commented Nov 8, 2019

@tschneidereit should confirm, but I think there is a strong argument for an explicit identifier as Wasm is strictly less privileged than JavaScript and whoever imports it might want to enforce those less privileged execution semantics.

(The only exception might be "top-level Wasm" which would somehow be able to get access to builtins in a way that is not yet defined. (I.e., when no JavaScript is involved.)

@littledan
Copy link
Member Author

I don't see it as that much less privileged, when anyone on the internet could make a module (with CORS headers and everything) that re-exports JS globals in a Wasm-friendly way.

@annevk
Copy link
Member

annevk commented Nov 8, 2019

Ah yes, if the Wasm module could still import a JavaScript module there's an easy workaround. The marker would have to apply recursively, but that would get complicated quickly (as Wasm should probably still be able to import JSON).

@littledan
Copy link
Member Author

It's a major goal of Wasm/ESM integration for Wasm to be able to import JS, too.

@annevk
Copy link
Member

annevk commented Nov 8, 2019

Understood, it would require some kind of hierarchy of privilege as noted in #7.

@bmeck
Copy link
Member

bmeck commented Nov 8, 2019

This brings to mind, is this use about allowing opt-in security about executing code or about preventing side effects? It seems a that exposing evaluation able modules in non-side effect manners has some importance if we are looking at treating Web Assembly as special given such. To that mind, would importing a JS module that only exported function declarations and did not have side effects on load be placed in a similar special category?

@littledan
Copy link
Member Author

I am not sure how to define that, but we should be able to add more categories over time once we have the infrastructure.

@devsnek
Copy link
Member

devsnek commented Nov 8, 2019

could also apply the same rules to wasm imports and require them to have a custom section with type:whatever. if you didn't want the wasm to load anything else, you probably shouldn't be importing it in the first place.

@xtuc
Copy link
Member

xtuc commented Nov 11, 2019

I like the custom section idea, a mapping between a module and attributes. I'm not sure how languages that compile to wasm will adopt it (if at all), but the mapping could be generated by a tool down the chain.

@littledan
Copy link
Member Author

@xtuc Great. One decent-sized piece of technical work will be to design the binary format of such a custom section. Are you interested in this task?

@littledan
Copy link
Member Author

(Note, maybe we should open a separate issue for the Wasm custom section, as it's a rather separate task from the decision about how we should mark things when importing WebAssembly.)

@xtuc
Copy link
Member

xtuc commented Nov 11, 2019

@littledan, I'm happy to do it. This work could be on the WebAssembly CG side since it's really seperate.

@littledan
Copy link
Member Author

@xtuc Agreed that this should be a WebAssembly CG proposal, but we could draft something early here and then split it out into a separate repo.

@littledan
Copy link
Member Author

Marking this as "follow-on proposal" as it's a decision for the WebAssembly/ESM integration proposal.

@xtuc
Copy link
Member

xtuc commented May 22, 2020

While this sounds like its own follow-up proposal. I'm concerned by what should be the module type when importing a Wasm module, which is a concret example of #16.

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

No branches or pull requests

5 participants