Skip to content

feat: sandboxing - #7758

Merged
aecsocket merged 234 commits into
mainfrom
boris/sandbox
Dec 2, 2026
Merged

aecsocket merged 234 commits into
mainfrom
boris/sandbox

Conversation

@aecsocket

@aecsocket aecsocket commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor
  • Re-enable toggling network in settings UI when possible

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Note

This changelog has been baked. Any further edits will not be reflected.

Pull request changelog

App

Added

  • Sandboxing, which launches instances in an isolated environment that limits what mods can access on Windows, macOS, and Linux.
    • The Sandboxing tab under Instance defaults in the app settings modal turns the sandbox on for all instances.
    • Sandboxed instances can use the network and read the Downloads folder by default unless you turn these options off.
    • Read-only access to the Documents folder and access to other folders you choose are available as toggle options.
    • Turning off the sandbox opens a confirmation modal that lists what a malicious mod could do without it.
    • Mods in a sandboxed instance can't read browser data, Discord data, SSH keys, or other launchers' account files.
    • File pickers, links, opening folders, and dragging files into the game work in sandboxed instances.
    • Multiplayer sign-in and Realms work in sandboxed instances, including on Minecraft 1.15 and older.
    • For more information see the news article.

Changed

  • The Java and memory, Window, Launch hooks, and Sandboxing tabs of instance settings show whether the instance uses your app defaults.
    • Select Customize to change these settings for that instance only.
    • Select Reset to app defaults to go back to the defaults from the Settings modal.
    • App settings replaces Manage default settings and opens the matching tab of the Settings modal.
  • Changes in the Settings modal, instance settings, and the Game settings modal now save as soon as you make them.
    • Removed the save and discard bar and the prompt about unsaved changes when you switch tabs or close.

Deprecated

Removed

Fixed

  • Fixed the missing apostrophe in the Don't install button of the unrecognized files warning.

Security

Website

Added

Changed

  • Changes on the Display, Language, Profile, and Social settings pages now save as soon as you make them, without a save bar.

Deprecated

Removed

Fixed

Security

Hosting

Added

Changed

Deprecated

Removed

Fixed

Security

@IMB11

IMB11 commented Nov 27, 2026

Copy link
Copy Markdown
Member

@greptileai review

}
}
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 security 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.

@greptile-apps

greptile-apps Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

security Security Review

This PR does not appear safe to merge because turning off "Access network" in the new sandbox settings has no effect - a sandboxed mod always keeps full internet access, so it can still exfiltrate data and receive remote commands.

What was checked
  • The localhost sandbox API on port 28881 requires a per-child bearer secret for /sandboxapi/* routes; the open /sandboxauth/* routes only proxy to fixed Mojang hosts.
  • The real Minecraft session token never reaches the sandboxed game - the game gets a dummy token and the launcher swaps in the real one only when forwarding to Mojang.
  • Sandbox path rules are enforced consistently for drag-dropped files, risky paths, and the launcher log (opened without following symlinks the game could plant).
  • All 71 SCA hits in Cargo.lock are pre-existing versions; this PR only adds new crates (fuser, libseccomp, ashpd, async_zip, etc.) with no advisories against them.
  • The bubblewrap, AppContainer, and Seatbelt backends honor the sandbox's allow_network flag, but the Minecraft command never sets it from user settings.

Findings

  • P1 Network toggle does nothing ▶
  • P2 Mods can probe which files exist ▶
  • P2 User-picked executables become writable ▶

@greptile-apps

greptile-apps Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 0/5 · The PR needs fixes before merging, especially for the sandbox install action and game-launch regressions.RetriggerView in GreptileConfidence Score: 0/5 Tier: plus

[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.

Summary

Adds a cross-platform Minecraft sandbox, a Java agent, sandbox settings, and installation prompts. It also switches several settings pages to automatic saving.

  • Minecraft launches can run inside a platform-specific sandbox.
  • Users can choose when Minecraft instances use the sandbox.
  • Install warnings can offer to sandbox unknown files.
  • Settings screens save changes directly or in smaller edits.
  • The game-settings editor saves changes as users make them.

Review used source inspection only; no builds or runtime checks were run.

Acknowledgments: aecsocket deferred re-enabling the network toggle. aecsocket’s added Windows grant documentation explicitly keeps a union of shared-container permissions to avoid breaking existing games.

Reviews (1) · Last reviewed commit: "refactor: remove unsaved changes popup i..." · Reviewed by Greptile

Comment on lines +194 to +198
JVM_ARGUMENTS.contains(&argument_name)
|| LAUNCHER_MANAGED_JVM_ARGUMENTS.contains(&argument_name)
|| argument.contains("${classpath}")
|| argument.contains("${natives_directory}")
|| argument.contains("${library_directory}")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 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.

Comment on lines +185 to +187
#[inline]
pub fn instance_data_dir(&self) -> PathBuf {
self.config_dir.join(INSTANCE_DATA_FOLDER_NAME)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 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.

Comment on lines +2180 to +2185
if let Err(errno) = rustix::fs::linkat(
old_dirfd,
&*old_path,
new_dirfd,
newname,
AtFlags::SYMLINK_NOFOLLOW,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

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.

@aecsocket
aecsocket merged commit 24db6b6 into main Dec 2, 2026
18 checks passed
@aecsocket
aecsocket deleted the boris/sandbox branch December 2, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

5 participants