Run a program in a bubblewrap sandbox. No profiles: the system is read-only, your real home is hidden, and the program gets a private home.
sbx firefox
sbx --net=none --here python3 script.py
sbx-gui is an optional GTK4/libadwaita editor for the settings files.
Needs Linux, Python 3.8+ and bubblewrap (0.8+ unless userns=1).
Optional: GTK 4 + libadwaita 1.5 + PyGObject (GUI), xdg-dbus-proxy (portals, tray, mpris, a11y, gnome_shell, kde, talk, own, bluetooth, battery, avahi), pasta (net_private), systemd-run (limits).
sudo apt install bubblewrap # or your distro's equivalent
sudo install -m755 sbx sbx-gui sbx-selftest sbx-report /usr/local/bin/
sbx doctor # checks everything works
Man page and completions:
sudo install -Dm644 sbx.1 /usr/local/share/man/man1/sbx.1
sudo install -Dm644 completions/sbx.bash /usr/local/share/bash-completion/completions/sbx
sudo install -Dm644 completions/_sbx /usr/local/share/zsh/site-functions/_sbx
sudo install -Dm644 completions/sbx.fish /usr/local/share/fish/vendor_completions.d/sbx.fish
sbx desktop --install-menu # sbx-gui in the app menu
sbx desktop --install-installer # right-click a folder or archive: Open With Other Application, Install in sbx
App-menu launchers: sbx desktop PATTERN copies the system launchers that match to ~/.local/share/applications with the program started through sbx, sbx desktop --remove PATTERN removes them. PATTERN is a launcher id (firefox), a glob over ids ('myapp*') or the program a launcher starts. --via=PROGRAM puts PROGRAM in front of each Exec unless it already starts with it, and --name=NAME gives them one home and settings name, so a family of launchers (myapp x.dat, notepad) shares one sandbox: sbx desktop --name=myapp --via=myapp 'myapp*'. Launchers starting with env, sh, bash or VAR= are skipped under --via, with a warning. --dry-run shows what would be written or removed and changes nothing; sbx-gui uses it for its preview.
Ubuntu 24.04+: AppArmor blocks user namespaces. sbx doctor shows the fix.
- System: read-only
- Your home: hidden, replaced by
~/.sbx-homes/NAME - Downloads, Documents, Pictures, Music, Videos: the program's own subfolder (e.g.
~/Downloads/sbx/NAME) shows up as that folder in its home; the rest of your folder stays hidden - Files you open with it ("Open with", a path argument), with
portals=1and PyGObject: read-only through the Documents portal, as Flatpak does /tmp,/run: empty tmpfs- Secrets (
/etc/shadow, SSH host keys, other users): emptied - Environment: cleared, except locale, terminal and desktop variables
- Network: shared unless
net=0ornet_private=1
It starts in its private home. Use full paths, or --here to share the current folder.
sbx [options] PROGRAM [args]
sbx preview ... print the command instead of running it
sbx show NAME settings that apply, and where each came from
sbx list programs you set up
sbx stop NAME
sbx clean NAME delete a private home
sbx reset NAME delete settings files, defaults apply again
sbx rebind NAME accept a moved program as the same one
sbx export [NAME] settings as one text file (-o FILE)
sbx import FILE load an export back
sbx link NAME typing NAME starts it through sbx
sbx open FILE run a downloaded program ("Open with")
sbx install SRC move a program (folder or archive) to ~/Apps/NAME, menu entry through sbx (--link: terminal command)
sbx uninstall NAME remove a program made by sbx install (--trash: its folder goes to the Trash)
Options go before the program name.
sbx install ~/Downloads/anki-26.9.4-linux-x86_64.tar.zst # or the extracted folder; NAME is guessed (anki), or give one
# an app-menu entry starts it through sbx; add --link for a terminal command (typing: anki)
sbx uninstall anki
The program goes to ~/Apps/NAME and is shared with it read-only. Its launcher loses the execute bit, so ./launcher outside sbx fails with "Permission denied" and only sbx can start it (sbx sets the bit for its own run; this works for dynamically linked programs, and static ones keep the bit with a warning). Files the program saves go to its private home. The other files in the folder keep their execute bit, because the program starts them itself inside the sandbox. A folder you install is moved, not copied; an archive is unpacked and left where it is. Nothing in it is run.
| Option | Effect |
|---|---|
--net=none |
no network |
--a11y |
a screen reader (Orca) can read the program, through a filtered accessibility bus (needs xdg-dbus-proxy) |
--gnome-shell |
the browser's GNOME Shell connector can list and install extensions, through a filtered session bus (needs xdg-dbus-proxy); --gnome-shell-manage also enable, disable, uninstall |
--kde |
the browser's Plasma integration works: downloads show as Plasma jobs, KRunner finds tabs and history, media controls, keep awake while downloading, through a filtered session bus (needs xdg-dbus-proxy) |
--net-private |
no localhost or local services (needs pasta) |
--private |
erase private home on exit |
--here |
share current folder, read-write |
--whitelist=PATH / --read-only=PATH |
share a path, read-write / read-only |
--no-share-dirs |
no per-program folders in Downloads, Documents, Pictures, Music, Videos |
--name=NAME |
separate home and settings |
--app-id=ID |
the id the desktop is told the program has (a launcher's file name without .desktop); sbx desktop sets it |
--memory=2G --tasks=512 --cpu=200% |
limits; they need systemd's memory, cpu, pids and io controllers for your user, and sbx warns (and sbx doctor shows the fix) when one is missing |
--io=low|normal|high |
disk priority against your other programs (a systemd IOWeight); only matters while programs compete for the disk, and only with the BFQ scheduler or io cost control. Setting: io |
--limits=light|balanced|heavy |
memory and CPU at 25 / 50 / 75% of this machine and a disk priority, wherever --memory, --cpu and --io are not set. Setting: limits |
--gtk-portal=auto|1|0 |
with --portals: tell GTK programs to use the file chooser portal. auto (default) does, except when your desktop's cursor size is 0, which crashes GTK (sbx says so); 1/0 force it. Setting: gtk_portal |
--linger=SECONDS |
how long what the program leaves behind after it exits (a second Firefox profile started from the first one's menu) may keep running before sbx ends it. Default: no limit, the program handles its own exit and the sandbox stays until its last process is gone (or sbx stop). With --linger=5, sbx SIGTERMs what is left after 5 s and SIGKILLs it 5 s later. Setting: linger |
--ignore-config |
ignore settings files |
Everything else: sbx --help, man sbx (includes downloaded and moved programs).
A name is tied to the file that first ran under it. A moved file with the same content keeps its program. Other content under the same file name takes over once the original is gone. Files a program wrote next to its own file move with it. If sbx can't tell, the program waits for sbx rebind NAME. Details: man sbx.
Plain key=value. ~/.config/sbx/default.conf applies to all programs, ~/.config/sbx/apps/NAME.conf to one.
net=0
portals=1
whitelist=~/Projects
memory=2G
A program that reads or creates files in the folder it starts in needs folder=1 (a switch in sbx-gui: "Start in the program's own folder"). It starts in the folder its file sits in and shares that folder read-write. The program must sit in a folder of its own: your home, Downloads, Desktop, Documents and hidden folders are never shared, and sbx warns why. --here is the same for the folder you are in. Without a folder setting, a program that sits in a folder named after it (G-Diffuser/, G-Diffuser-v1.2.3-linux-x64/) gets this automatically, and sbx says so on start. folder=0 turns that off.
Per-program folders: for each of Downloads, Documents, Pictures, Music and Videos that is set in ~/.config/user-dirs.dirs and exists, <folder>/sbx/NAME is mounted over the same folder in the private home (~/Downloads/sbx/firefox is ~/Downloads for firefox). The program sees only its own files there. share_dirs=Downloads,Pictures picks some, share_dirs= (or --no-share-dirs) turns it off, and sbx-gui has a switch on each program's page and on the defaults page. Files the program's private home already holds in those folders are moved over on first use, never overwriting. sbx creates the folders with mode 0700 and never deletes them, empty or not; if sbx or sbx/NAME is a link, sbx warns and that folder stays in the private home. private=1 ignores it. sbx clean removes only the private home.
Launch arguments: args=--profile work in a program's settings file adds those arguments, split like a shell would, before the ones you type (sbx-gui has a row for it on each program's page).
Environment variables: setenv=NAME=value sets one for the program, env=NAME passes your own value through (also --setenv=NAME=value). sbx-gui has a list for both on each program's page.
D-Bus names: talk=org.freedesktop.FileManager1 (or --talk=NAME) lets the program call that session-bus name through xdg-dbus-proxy. It gives full access to that service, so list only what the program needs. A wildcard needs three parts before the .* (org.example.App.*). own=NAME (or --own=NAME) also lets the program register that name, which includes talking to it: own=org.mozilla.firefox.* lets a second Firefox launch reach the running one instead of stopping with "already running". sbx-gui has a list for each.
bluetooth=1, battery=1 and avahi=1 (or --bluetooth, --battery, --avahi) open one system-bus name each: org.bluez, org.freedesktop.UPower, org.freedesktop.Avahi (Web Bluetooth, the battery API, Cast and network discovery in Chrome). The program gets a filtered copy of the system bus with only those names. Bluetooth reaches nearby devices even with net=0, and Avahi lists the services on your local network.
sbx show NAME lists every setting. Flags beat files and can only make things stricter.
Back up or move settings with sbx export -o FILE and sbx import FILE (--force replaces settings that differ); sbx-gui has the same buttons.
sbx-trace is a separate program, not part of this repository. It runs a program under bpftrace and reports which files it opened, looked for or changed, and which attempts failed (refused, read-only, or hidden by the sandbox). It works with sbx: sbx-trace sbx firefox traces a program in the sandbox, and sbx-trace --suggest prints read_only= / whitelist= lines for what was refused.
python3 test_sbx.py # all tests (isolation tests need bubblewrap)
sbx ./sbx-selftest # inside the sandbox: every row should say PASS
sbx ./sbx-report # what the program can reach
Failed runs are logged to ~/.local/state/sbx/sbx.log.
sbx and sbx-gui are generated. Edit src/ and src/gui/, run python3 build.py, commit the result. python3 build.py --check runs in CI.
- Convenience sandbox, not a security boundary against hostile programs. The syscall filter is a blocklist, plus an allowlist for
socket(): unix, inet, inet6 and netlink only. - Wayland without security-context support gives the program the full socket (a warning is shown).
wayland_strictis on by default where the compositor supports security contexts, so a failed attempt there gives no Wayland instead of the full socket; where it can't, it is off and sbx-gui greys the switch out. Set it yourself to override. net_private=1is not a firewall: your local network stays reachable.- Read-write shares (
--here,whitelist=) let the program plant files that later run outside the sandbox. Share only what it needs. - 32-bit programs fail by default.
allow_32bit=1(--allow-32bit) lets them run on x86_64 with the same blocklist, with a warning, becausesocketcall()(how 32-bit libcs reachsocket(),connect(),send()...) hides its arguments in memory, so a filter can't check them: through it, thesocket()family allowlist does not apply to 32-bit programs. If a 32-bit program fails while it is off, sbx says so in its message and in the log. Terminal programs have no/dev/tty, so password prompts don't work. - One private home per name: use
--namefor separate ones.
GPL-3.0-or-later. See LICENSE.
