Repository navigation
feat: sandboxing - #7758
feat: sandboxing#7758aecsocket wants to merge 216 commits into
Conversation
Pull request changelogAppAddedChangedDeprecatedRemovedFixedSecurityWebsiteAddedChangedDeprecatedRemovedFixedSecurityHostingAddedChangedDeprecatedRemovedFixedSecurity |
…f writing on every launch
…aining home (bwrap)
# Conflicts: # Cargo.lock # Cargo.toml # apps/app-frontend/src/locales/de-CH/index.json # apps/app-frontend/src/locales/de-DE/index.json # apps/app-frontend/src/locales/it-IT/index.json # apps/app-frontend/src/locales/ko-KR/index.json # apps/app-frontend/src/locales/pt-BR/index.json # apps/app-frontend/src/locales/ru-RU/index.json # apps/app-frontend/src/locales/sv-SE/index.json # apps/app-frontend/src/locales/uk-UA/index.json # apps/app-frontend/src/locales/zh-TW/index.json # packages/app-lib/Cargo.toml # packages/app-lib/src/launcher/args.rs # packages/app-lib/src/launcher/mod.rs # packages/app-lib/src/state/process.rs
|
Tick the box to add this pull request to the merge queue (same as
|
|
@greptileai review |
| "rejecting dropped-file access because the file is not a readable ZIP archive" | ||
| ); | ||
| return Err(RequestStatus::InternalServerError); | ||
| }; |
There was a problem hiding this comment.
Mods can probe which files exist
Mods can check which host files exist. handle_request_request_access returns InternalServerError (500) when the probed path exists but is not a readable ZIP, returns Unauthorized (401) when the path does not exist, and only sets the disallow_request_access kill switch on the nonexistent case. The handler's own comments say it exists to stop a malicious program from enumerating files, but the distinct status codes leak the answer anyway: a mod inside the sandbox can probe an arbitrary host path outside its grants and tell whether the file exists. For example, a mod requests access to ~/secret.dat; a 500 means the file exists, a 401 means it does not. "Exists" answers never trigger the kill switch, so the mod can enumerate any number of existing files across a session. Return the same error status (and the same logging) for every rejection reason, and trigger the kill switch on any failed probe, not just missing paths.
| } | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
User-picked executables become writable
User-picked executables get write access. When a mod triggers a file dialog, handle_request_open_file_dialog exposes every path the user picks as ReadWrite, with no downgrade for executable or script extensions. The drag-and-drop path does the opposite: get_drop_permission in drag_intercept.rs forces directories and anything with an executable extension to ReadOnly, explicitly "to prevent the sandboxed process from modifying anything which could later be executed outside of the sandbox". The dialog's title, accept label, filters, and default location are all mod-controlled, so a mod can social-engineer the user into selecting an existing .bat, .ps1, or .jar (e.g. a fake "export your log" save dialog with a *.bat filter). The sandbox then gets write access to that file, the mod overwrites it, and the code runs outside the sandbox the next time the user opens it. Apply the same executable-extension downgrade to paths picked through the dialog.
[High impact] The PR changes how Minecraft processes run and how several app settings are edited. The PR needs fixes before merging, especially for the sandbox install action and game-launch regressions.
|
| JVM_ARGUMENTS.contains(&argument_name) | ||
| || LAUNCHER_MANAGED_JVM_ARGUMENTS.contains(&argument_name) | ||
| || argument.contains("${classpath}") | ||
| || argument.contains("${natives_directory}") | ||
| || argument.contains("${library_directory}") |
There was a problem hiding this comment.
Required loader arguments disappear
Filtering every argument containing ${library_directory} or ${classpath} removes loader-specific arguments too. Forge and NeoForge use these placeholders for their module path and properties such as legacyClassPath. Removing a module-path value leaves its preceding option in place, so Java reads the next option as its value and the game fails to start—even with sandboxing off.
Substitute these placeholders and remove only the options the new command actually rebuilds.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/app-lib/src/launcher/args.rs
Line: 194-198
Comment:
**Required loader arguments disappear**
Filtering every argument containing `${library_directory}` or `${classpath}` removes loader-specific arguments too. Forge and NeoForge use these placeholders for their module path and properties such as `legacyClassPath`. Removing a module-path value leaves its preceding option in place, so Java reads the next option as its value and the game fails to start—even with sandboxing off.
Substitute these placeholders and remove only the options the new command actually rebuilds.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| #[inline] | ||
| pub fn instance_data_dir(&self) -> PathBuf { | ||
| self.config_dir.join(INSTANCE_DATA_FOLDER_NAME) |
There was a problem hiding this comment.
Persistent game data stays behind
The new instance-data folder is missing from MOVED_APP_DIRECTORIES. After the user moves the app directory, instance_data_dir() points under the new root, but the move copies only its existing six folders. Minecraft gets a fresh home and cannot find the mod data saved in the old location.
Include this folder in the copy and path-mapping work.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/app-lib/src/state/dirs.rs
Line: 185-187
Comment:
**Persistent game data stays behind**
The new `instance-data` folder is missing from `MOVED_APP_DIRECTORIES`. After the user moves the app directory, `instance_data_dir()` points under the new root, but the move copies only its existing six folders. Minecraft gets a fresh home and cannot find the mod data saved in the old location.
Include this folder in the copy and path-mapping work.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| let rt = tokio::runtime::Builder::new_current_thread() | ||
| .build() | ||
| .context("creating tokio runtime")?; | ||
| let env = rt.block_on(SandboxEnv::new())?; |
There was a problem hiding this comment.
modrinth_sandbox_create_env builds a Tokio runtime without enabling its I/O or time drivers. In Flatpak, SandboxEnv::new() immediately connects to the session bus through Tokio, so this function panics instead of creating the environment. A panic crossing extern "C" aborts the caller.
Use .enable_all(), as the no-op constructor already does.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/modrinth-sandbox/src/ffi/env.rs
Line: 33-36
Comment:
**C sandbox startup aborts**
`modrinth_sandbox_create_env` builds a Tokio runtime without enabling its I/O or time drivers. In Flatpak, `SandboxEnv::new()` immediately connects to the session bus through Tokio, so this function panics instead of creating the environment. A panic crossing `extern "C"` aborts the caller.
Use `.enable_all()`, as the no-op constructor already does.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| if let Err(errno) = rustix::fs::linkat( | ||
| old_dirfd, | ||
| &*old_path, | ||
| new_dirfd, | ||
| newname, | ||
| AtFlags::SYMLINK_NOFOLLOW, |
There was a problem hiding this comment.
Linux linkat does not accept AT_SYMLINK_NOFOLLOW; not following the source link is already its default. Passing AtFlags::SYMLINK_NOFOLLOW makes every hard-link request through this file-sharing filesystem fail with EINVAL.
Pass empty flags so mods can create hard links in shared folders.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/modrinth-sandbox/src/backend/linux/file_sharing.rs
Line: 2180-2185
Comment:
**Shared-folder hard links fail**
Linux `linkat` does not accept `AT_SYMLINK_NOFOLLOW`; not following the source link is already its default. Passing `AtFlags::SYMLINK_NOFOLLOW` makes every hard-link request through this file-sharing filesystem fail with `EINVAL`.
Pass empty flags so mods can create hard links in shared folders.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Uh oh!
There was an error while loading. Please reload this page.