-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Capabilities granularity too low #90
Comments
My rough idea is that Mandatory Access Control (MAC) is out of scope for WASI, at least for now. That is, at the point of resolving a filesystem path or configuring a network socket or otherwise obtaining a new resource handle, the host environment may be permitted to apply additional rules to determine if access should be granted, such as SELinux or other systems. As you say, this can be pretty complex. For filesystem support, WASI currently has a directory-oriented capability model. Wasm code can be granted access to a directory, providing it access to the contents of that directory. This access can be restricted to being readonly or other things, but there's no finer-grained path filtering currently. For networking support, my rough idea (mentioned here) is that we could introduce a kind of capability which represents a set of sockets that can be created. For TCP-like sockets, this might look like a set of address (source and destination), port (source and destination), and protocol tuples that application code might create and configure a socket on. My rough idea for both of these is to look for sweet-spot solutions that work for the majority of cases while still being really simple, and leave the more specialized cases to host/environment-specific mechanisms outside of WASI. However, this may also be a result of my lacking experience with BPF-style filtering -- to me, it sounds more complex, sounds like functionality that's only needed in highly specialized circumstances, and any time you add a new turing-complete mechanism to an overall system in a security-relevant area, my generic experience is that you have to be very very cautious. However, if someone who has more experience with BPF or similar mechanisms wanted to make a writeup showing how it would work for WebAssembly, it'd be a great topic for the CG subgroup to discuss. |
@sunfishcode I don't understand how capabilities are in scope for WASI. Could you clarify this? APIs don't enforce capabilities, implementations of those APIs do. |
As an example, let's say we have TCP-like sockets. We want to restrict the WASM to |
Continuing the discussion here now that we have a dedicated repo. |
* Mark public API functions as unsafe. This marks the public hostcalls functions as unsafe. This is generalizing from Rust's `from_raw_fd` function, which is unsafe. The observation is that nothing prevents code using this function from passing a bogus or stale dangling file descriptor and corrupting an arbitrary open stream. Technically, some of these functions don't use file descriptors, such as random, clocks, and a few others. However I expect that in the future, random and clocks will switch to using file descriptors anyway, and it keeps the macro definitions simpler if we only have to handle one form. * Mark WasiCtx functions that operate on file descriptors unsafe too. * `fd_filestat_set_times_impl` doesn't need to be unsafe. * Remove unnecessary unsafes
* Add first bench * Refactor travis.yml * Use assert_matches! * sha3_256 → keccak256
…rt_preopens_environment_2 Import functions provide environment variables and preopens
…rt_preopens_environment_2 Import functions provide environment variables and preopens
This patch adds a few WasmFX + WASI test programs to the testsuite. The tests are run in both sync and async mode.
Most existing capability-based systems have either of the following issues.
Too low granularity of capabilities (an app can access network, but actually should be allowed to access e.g. just several OSI 4 or higher protocols, have limited bandwidth, shouldn't have access to any OSI 3 or lower information, etc.)
Too high granularity (e.g. SELinux is super complex which is contra-productive as it's therefore quite often ignored or quite incorrectly configured)
To solve this, capabilites shouldn't be fix, but rather shall be a turing-complete executable code/assembly (imagine Linux BPF JIT). Then one can provide a standard library with low-grained capability-building-blocks (like e.g. Android does) and allow for fine-grained specification in all scenarios.
How do you want to approach this granularity/complexity issue in WASI?
The text was updated successfully, but these errors were encountered: