Skip to main content

A bubblewrap (bwrap) wrapper for sandboxing commands

Project description

bwrapwrap

A bubblewrap wrapper that sandboxes commands with sensible defaults. Network is blocked, the filesystem is read-only (except the current directory), and namespaces are unshared — all with a single command.

Prerequisites

sudo apt install bubblewrap

Optional, for --fork overlay mode:

sudo apt install fuse-overlayfs

Installation

pipx install .

Or for development:

pipx install -e .

Usage

bww [OPTIONS] <command> [args...]

Options

Flag Description
--net Allow network access (blocked by default)
--ptrace Allow ptrace (for strace/gdb)
--fork [NAME] Fork ~/.claude via fuse-overlayfs into ~/.bww/NAME/
--fork-cleanup Delete the fork directory on exit
--dry-run Print the bwrap command without running it
--help, -h Show help

Examples

# Run a script with no network
bww python3 script.py

# Allow network access
bww --net curl https://example.com

# Run claude with real ~/.claude bound read-write
bww --net claude

# Fork ~/.claude into a copy-on-write overlay
bww --fork --net claude

# Named fork (resumable)
bww --fork=experiment --net claude

# Inspect the generated bwrap command
bww --dry-run echo hello

What gets mounted

Mount Mode
/usr, /lib, /lib64, /bin, /sbin read-only
/etc/alternatives, /etc/fonts, /etc/ssl, /etc/ca-certificates read-only
/proc, /dev standard
/tmp tmpfs
Current working directory read-write
~/.cargo, ~/.rustup (if they exist) read-only
PATH directories read-only
~/.claude/projects/<cwd-session>/ (claude only) read-write
~/.claude/{.credentials.json,settings.json,CLAUDE.md} (claude only) read-only

Claude detection

When the command name contains "claude", bww binds only the project session directory for the current working directory (~/.claude/projects/<encoded-cwd>/) read-write. Shared config files (.credentials.json, settings.json, CLAUDE.md) are bound read-only. Other projects' session data is never exposed. Use --fork to isolate writes into a copy-on-write overlay instead.

Testing

pip install -e ".[test]"
pytest tests/ -v

To test against the original bash script:

SANDBOX_BIN=./sandbox.bash pytest tests/ -v

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bwrapwrap-0.1.1.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bwrapwrap-0.1.1-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

Details for the file bwrapwrap-0.1.1.tar.gz.

File metadata

  • Download URL: bwrapwrap-0.1.1.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bwrapwrap-0.1.1.tar.gz
Algorithm Hash digest
SHA256 bc467e51ce41b1c1640471be3d30ba255c36fd062b51f20559d91bc3b5a1b2c2
MD5 702480465a5e6971bce50f96952339bc
BLAKE2b-256 825cf315d5d7d6585e2ffb1692e4eef705e0d291c2b90d4f2cd7d70b2f8e18d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for bwrapwrap-0.1.1.tar.gz:

Publisher: publish.yml on lirazsiri/bwrapwrap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bwrapwrap-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: bwrapwrap-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 18.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bwrapwrap-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 05e029636153e311603dffc44bd3b5e737054280d4b9e0253d9e3d29cad993d0
MD5 7f013a9ca8778a894af99ee75d5c7200
BLAKE2b-256 40f22f1ca70316305f4d48e1a40ff58355bed0318c0f72c6c20aaa6a3011c93b

See more details on using hashes here.

Provenance

The following attestation bundles were made for bwrapwrap-0.1.1-py3-none-any.whl:

Publisher: publish.yml on lirazsiri/bwrapwrap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page