Mozilla has announced a new standardization effort to provide a consistent way for WebAssembly applications to interact with any operating system they run on.
Dubbed WASI, or WebAssembly System Interface, the currently experimental project provides WebAssembly applications with a set of abstractions for performing tasks such as reading and writing files and network I/O. Each WebAssembly host implements WASI for the platform it runs on.
Another key element of WASI is that these behaviors are sandboxed. One example given by Mozilla is file access. A WASI-managed call to open a file would only work for the directories the application has explicit permission to read from or write to. Those permissions could also be limited per module.
Using WASI will require recompiling existing WebAssembly to work correctly, but WebAssembly is still early enough in its development that a change like this isn’t likely to be disruptive. Right now, two of the major toolchains for writing WebAssembly apps, Rust and C/C++, support WASI. Both leverage LLVM’s ability to generate WebAssembly code to achieve this.