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

Proposal: add the ability to declare read only memories #1398

Closed
dbezhetskov opened this issue Feb 26, 2021 · 1 comment
Closed

Proposal: add the ability to declare read only memories #1398

dbezhetskov opened this issue Feb 26, 2021 · 1 comment

Comments

@dbezhetskov
Copy link

The story begins from this article https://www.usenix.org/conference/usenixsecurity20/presentation/lehmann
Daniel Lehmann and the company show the example of how to use undefined behavior in C/C++ to call any js function from the browser.

Of course, wasm is safe and sound but when you emulate unsafe languages like C/C++ inside wasm memory you can obviously spoil that memory. For example, Emscripten emulates C++ stack pointer and stores return addresses inside wasm memory so with a simple buffer overflow you can spoil some valuable data. Things become more dramatic when you import eval function from js and give wasm access to it.

The suggestion from the article is to implement the same protection mechanisms as for native software - stack canaries and read-only memory pages.

Stack canaries can be implemented without any support from the language, but the ability to declare read-only memory pages looks promising.

I want to propose the new flag:
new WebAssembly.Memory({initial:10, maximum:100, read-only: true});
This change actually is easy to implement and it doesn't break any binary interfaces.

With the multiple memory proposal, it will help to represent constant data inside wasm memories.

@dbezhetskov dbezhetskov changed the title Proposal: add the ability to declare read only memory instances Proposal: add the ability to declare read only memories Feb 26, 2021
@dbezhetskov
Copy link
Author

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