Disallow mounting folders on the guest's root for WASIX modules#5475
Disallow mounting folders on the guest's root for WASIX modules#5475
Conversation
|
📝 Documentation updates detected! A separate PR for documentation updates has been made here: wasmerio/docs.wasmer.io#122 |
|
Also, Tested-by: Charalampos Mitrodimas charalampos@wasmer.io |
|
This PR might have some implications, that we don't want. I remember other programs using |
|
@syrusakbary in fact, that's exactly what this PR is trying to prevent. Mounting things on
|
|
@Arshia001 The PR seems to be pretty close to be merged, can you rebase it? |
3d9591b to
e83e944
Compare
e83e944 to
db04d04
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds validation to prevent mounting folders on the guest's root directory ("/") for WASIX modules, addressing a security and filesystem organization concern. The restriction is enforced at multiple levels of the stack to ensure comprehensive coverage.
- Added
is_wasixparameter throughout the call chain to differentiate WASIX from regular WASI modules - Implemented validation checks in package loading, filesystem mounting, and CLI argument processing
- Created a new error type
MountOnRootfor clear error reporting
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
lib/wasix/src/runtime/package_loader/load_package_tree.rs |
Added validation in filesystem_v3 and filesystem_v2 to reject mounts at "/"; removed unused sorting code |
lib/package/src/package/package.rs |
Added MountOnRoot error variant and validation check in Package construction for wasmer.toml files |
lib/cli/src/commands/run/wasi.rs |
Added is_wasix parameter to build_mapped_directories with validation for --dir=/ and --mapdir /:<HOST_PATH> flags; adjusted default guest paths based on module type |
lib/cli/src/commands/run/mod.rs |
Added is_wasix parameter to build_wasi_runner and updated all call sites to pass appropriate value (hardcoded true for webcs, dynamically determined for modules) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@syrusakbary since we turned the errors into warnings, there's not much we can actually test. |
zebreus
left a comment
There was a problem hiding this comment.
The only thing that really changed is
if is_wasix {
MAPPED_CURRENT_DIR_DEFAULT_PATH.to_string()
} else {
"/".to_string()
},
| guest: MAPPED_CURRENT_DIR_DEFAULT_PATH.to_string(), | ||
| guest: if is_wasix { | ||
| MAPPED_CURRENT_DIR_DEFAULT_PATH.to_string() | ||
| } else { | ||
| "/".to_string() | ||
| }, |
There was a problem hiding this comment.
This is the only thing that really changed. I don't understand why this change is made and if it is an improvement.
There was a problem hiding this comment.
@Arshia001 If you are 100% certain this is a good idea, then go ahead and merge
There was a problem hiding this comment.
@zebreus this is kind of the main issue! With WASI modules, nothing is mounted in the module's FS by default, so it's OK to mount wherever. With WASIX, we mount a lot of stuff in by default, so you don't want a mount on the root.
Now, with WASI, since there is no host-side CWD and you're at / by default, you just have to mount directly in / to make the files available to the module with relative paths. With WASIX, we mount into /home and cd into it.
There was a problem hiding this comment.
What I don't understand is that when MAPPED_CURRENT_DIR_DEFAULT_PATH is already defined to /home and that seems to work just fine.
If I understand you correctly the reason for the change is to make sure that the mountpoint is always the CWD, which it can't be for WASI. But we also can't always mount to / because that won't work for WASIX...
There was a problem hiding this comment.
So in the past, the dir was just mounted to /home for WASI and now it isn't anymore. While this could be breaking, it's probably an improvement. However I don't like that it's one more inconsistency.
No description provided.