sbe-core 0.4.0

Core library for sbe — cross-platform sandbox executor for supply chain defense
Documentation
# sbe built-in default profiles — Linux.
# Embedded into the binary at compile time via include_str!.
#
# Path conventions:
#   ~ expands to home dir, $PWD to working directory
#   Trailing / means directory → Landlock path-beneath (recursive match)
#   No trailing / means file   → Landlock path-beneath on the file FD only
#
# Per the cross-platform-backend-design spec (§8) Linux differs from macOS:
#   - denyRead is sealed forbidden-list, not a subtractive deny (see §8).
#   - allowExec MUST be per-binary literals — directory subpaths defeat
#     the threat model on Linux (a /usr/bin subpath grants sudo).
#   - denyExec removes overlapping entries from the final allowExec set.

common:
  # The project is readable but not broadly writable. The Linux compiler
  # carves denyRead paths (for example .env) out of this subtree instead of
  # granting a single parent rule, because Landlock has no subtractive deny.
  allowRead:
    - "$PWD/"

  # Sealed forbidden-read list. The Linux backend refuses to silently add
  # these paths to the read allowlist, even via user config.
  denyRead:
    # SSH / GPG
    - "~/.ssh/"
    - "~/.gnupg/"
    # Cloud credentials
    - "~/.aws/"
    - "~/.azure/"
    - "~/.config/gcloud/"
    - "~/.kube/config"
    # Container / registry auth
    - "~/.docker/config.json"
    - "~/.netrc"
    # Password managers
    - "~/.password-store/"
    # Package manager tokens
    - "~/.cargo/credentials.toml"
    - "~/.cargo/credentials"
    - "~/.pypirc"
    - "~/.hex/hex_api_key"
    - "~/.config/gh/"
    # Environment secrets
    - "$PWD/.env"
    - "$PWD/.env.local"
    - "$PWD/.env.production"
    # Browser profiles
    - "~/.mozilla/"
    - "~/.config/google-chrome/"
    - "~/.config/chromium/"
    - "~/.config/BraveSoftware/"

  # Linux realizes denyExec by removing any overlapping allowExec entry. A
  # directory allow may therefore be removed in full to fail closed.
  denyExec: []

  allowExec:
    # Shells
    - "/bin/sh"
    - "/bin/bash"
    - "/bin/dash"
    - "/usr/bin/env"
    - "/usr/bin/sh"
    - "/usr/bin/bash"
    - "/usr/bin/dash"
    # Core utilities — each one explicit (no /usr/bin subpath)
    - "/bin/cat"
    - "/bin/cp"
    - "/bin/mv"
    - "/bin/rm"
    - "/bin/mkdir"
    - "/bin/rmdir"
    - "/bin/ls"
    - "/bin/ln"
    - "/bin/chmod"
    - "/bin/date"
    - "/bin/echo"
    - "/bin/dd"
    - "/bin/sleep"
    - "/usr/bin/cat"
    - "/usr/bin/cp"
    - "/usr/bin/mv"
    - "/usr/bin/rm"
    - "/usr/bin/mkdir"
    - "/usr/bin/rmdir"
    - "/usr/bin/ls"
    - "/usr/bin/ln"
    - "/usr/bin/chmod"
    - "/usr/bin/date"
    - "/usr/bin/echo"
    - "/usr/bin/basename"
    - "/usr/bin/dirname"
    - "/usr/bin/head"
    - "/usr/bin/tail"
    - "/usr/bin/cut"
    - "/usr/bin/tr"
    - "/usr/bin/sed"
    - "/usr/bin/awk"
    - "/usr/bin/grep"
    - "/usr/bin/sort"
    - "/usr/bin/uniq"
    - "/usr/bin/wc"
    - "/usr/bin/tee"
    - "/usr/bin/xargs"
    - "/usr/bin/find"
    - "/usr/bin/touch"
    - "/usr/bin/mktemp"
    - "/usr/bin/install"
    - "/usr/bin/test"
    - "/usr/bin/expr"
    - "/usr/bin/printf"
    - "/usr/bin/readlink"
    - "/usr/bin/uname"
    - "/usr/bin/which"
    - "/usr/bin/file"
    - "/usr/bin/stat"
    - "/usr/bin/sleep"
    # Archive / compression
    - "/usr/bin/tar"
    - "/usr/bin/gzip"
    - "/usr/bin/gunzip"
    - "/usr/bin/bzip2"
    - "/usr/bin/bunzip2"
    - "/usr/bin/xz"
    - "/usr/bin/zstd"
    - "/usr/bin/unzip"
    - "/usr/bin/zip"
    # Build toolchain — each binary explicit
    - "/usr/bin/cc"
    - "/usr/bin/gcc"
    - "/usr/bin/g++"
    - "/usr/bin/clang"
    - "/usr/bin/clang++"
    - "/usr/bin/ld"
    - "/usr/bin/ld.gold"
    - "/usr/bin/ld.lld"
    - "/usr/bin/as"
    - "/usr/bin/ar"
    - "/usr/bin/ranlib"
    - "/usr/bin/strip"
    - "/usr/bin/nm"
    - "/usr/bin/objdump"
    - "/usr/bin/objcopy"
    - "/usr/bin/make"
    - "/usr/bin/cmake"
    - "/usr/bin/pkg-config"
    - "/usr/local/bin/cmake"
    - "/usr/local/bin/pkg-config"
    # GCC launches versioned, architecture-specific helpers such as
    # collect2, cc1, and lto-wrapper from these immutable compiler-only
    # trees. Keep the grant narrower than /usr/lib or /usr/libexec.
    - "/usr/libexec/gcc/"
    - "/usr/lib/gcc/"
    # Dynamic linker — Landlock EXECUTE is required to start any
    # dynamically-linked binary on Linux.
    - "/lib64/ld-linux-x86-64.so.2"
    - "/lib/ld-linux-x86-64.so.2"
    - "/lib/ld-linux-aarch64.so.1"
    - "/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1"
    # Git (used by cargo, mix deps.get, etc.)
    - "/usr/bin/git"
    - "/usr/local/bin/git"

profiles:
  node:
    allowWrite:
      - "$PWD/node_modules/"
      - "$PWD/package-lock.json"
      - "$PWD/yarn.lock"
      - "$PWD/pnpm-lock.yaml"
      - "$PWD/bun.lock"
      - "$PWD/.yarn/"
      - "$PWD/.pnp.cjs"
      - "$PWD/.pnp.loader.mjs"
      - "~/.npm/"
      - "~/.cache/yarn/"
      - "~/.yarn/"
      - "~/.local/share/pnpm/"
      - "~/.bun/"
      - "~/.cache/bun/"
    allowDomains:
      - "registry.npmjs.org"
      - "registry.yarnpkg.com"
      - "registry.npmmirror.com"
      - "github.com"
      - "codeload.github.com"
      - "objects.githubusercontent.com"
    allowExec:
      - "/usr/local/bin/node"
      - "/usr/bin/node"
      - "/usr/bin/npm"
      - "/usr/bin/npx"
      - "/usr/local/bin/npm"
      - "/usr/local/bin/npx"
      - "/usr/local/bin/yarn"
      - "/usr/local/bin/pnpm"
      - "/usr/local/bin/bun"
      - "~/.nvm/"
      - "~/.volta/"
      - "~/.fnm/"
      - "~/.local/share/fnm/"
      - "~/.local/state/fnm_multishells/"
      # GitHub Actions setup-node installs versioned toolchains here.
      - "/opt/hostedtoolcache/node/"
      # mise (polyglot version manager)
      - "~/.local/share/mise/"
      # asdf shim layout
      - "~/.asdf/"

  rust:
    allowRead:
      # The rustup proxy reads its selected toolchain from this non-secret
      # settings file before dispatching cargo/rustc. Toolchain contents are
      # already read+execute via allowExec below.
      - "~/.rustup/settings.toml"
    allowWrite:
      - "$PWD/target/"
      - "$PWD/Cargo.lock"
      - "~/.cargo/registry/"
      - "~/.cargo/git/"
      # NOTE: ~/.cargo/bin/ is NOT writable — prevents trojaning cargo binaries
      - "~/.cache/zig/"
    allowDomains:
      - "crates.io"
      - "static.crates.io"
      - "index.crates.io"
      - "static.rust-lang.org"
      - "github.com"
      - "codeload.github.com"
      - "objects.githubusercontent.com"
    allowExec:
      - "~/.cargo/bin/"
      - "~/.rustup/toolchains/"

  python:
    allowWrite:
      - "$PWD/uv.lock"
      - "$PWD/poetry.lock"
      - "$PWD/pdm.lock"
      - "$PWD/dist/"
      - "$PWD/build/"
      - "~/.cache/pip/"
      - "~/.cache/uv/"
      - "~/.local/lib/"
      # NOTE: ~/.local/bin/ is NOT writable — prevents trojaning user binaries
      - "$PWD/.venv/"
      - "$PWD/venv/"
      # Poetry cache
      - "~/.cache/pypoetry/"
      # PDM cache
      - "~/.local/share/pdm/"
    allowDomains:
      - "pypi.org"
      - "files.pythonhosted.org"
      - "github.com"
      - "codeload.github.com"
      - "objects.githubusercontent.com"
    allowExec:
      - "/usr/bin/python3"
      - "/usr/local/bin/python3"
      - "/usr/bin/pip3"
      - "/usr/local/bin/pip3"
      - "/usr/local/bin/uv"
      - "/usr/bin/uv"
      # GitHub Actions setup-python installs versioned interpreters here.
      - "/opt/hostedtoolcache/Python/"
      # GitHub Actions setup-uv installs versioned binaries here.
      - "/opt/hostedtoolcache/uv/"
      - "/usr/local/bin/poetry"
      - "/usr/local/bin/pdm"
      # Version managers
      - "~/.pyenv/"
      - "~/.local/bin/"
      # uv-managed Python installations
      - "~/.local/share/uv/"
      # Rye-managed Python
      - "~/.rye/"
      # mise (polyglot version manager)
      - "~/.local/share/mise/"
      # asdf
      - "~/.asdf/"

  elixir:
    allowWrite:
      - "$PWD/deps/"
      - "$PWD/_build/"
      - "$PWD/mix.lock"
      - "~/.hex/"
      - "~/.mix/"
      - "~/.cache/rebar3/"
    allowDomains:
      - "hex.pm"
      - "repo.hex.pm"
      - "builds.hex.pm"
      - "cdn.hex.pm"
      - "github.com"
      - "codeload.github.com"
      - "objects.githubusercontent.com"
    allowExec:
      - "/usr/bin/elixir"
      - "/usr/bin/mix"
      - "/usr/bin/iex"
      - "/usr/bin/erl"
      - "/usr/bin/epmd"
      - "/usr/local/bin/elixir"
      - "/usr/local/bin/mix"
      - "/usr/local/bin/iex"
      - "/usr/local/bin/erl"
      - "/usr/local/bin/epmd"
      # erl is a launcher; the versioned ERTS VM and helpers (erlexec,
      # inet_gethost, beam.smp) live below this immutable runtime tree.
      - "/usr/lib/erlang/"
      # Version managers
      - "~/.asdf/"
      - "~/.kiex/"
      - "~/.local/share/mise/"

  java:
    # SBE injects authenticated JVM proxy properties after allocating the
    # per-run proxy port, so Maven/sbt HTTPS stays on the exact proxy route.
    enableProxy: true
    # Maven keeps `settings.xml` and `settings-security.xml` at the `~/.m2/`
    # root, not under `repository/`. Landlock's per-path grant means we have
    # to allow read on the parent explicitly — on macOS SBPL this works
    # implicitly because reads are allowed-by-default.
    allowRead:
      - "~/.m2/"
      - "~/.sbt/"
      - "~/.ivy2/"
      - "~/.gradle/"
    allowWrite:
      - "~/.m2/repository/"
      - "$PWD/.gradle/"
      - "$PWD/build/"
      - "$PWD/target/"
      - "$PWD/project/target/"
      - "$PWD/project/project/"
      # Scala / sbt
      # sbt's XDG runtime socket and tool caches are redirected to SBE's
      # private per-run directory by the launcher environment.
    allowDomains:
      - "repo1.maven.org"
      - "repo.maven.apache.org"
      - "plugins.gradle.org"
      - "services.gradle.org"
      - "downloads.gradle.org"
      - "downloads.gradle-dn.com"
      - "jcenter.bintray.com"
      - "github.com"
      - "codeload.github.com"
      - "objects.githubusercontent.com"
      # Scala
      - "repo.scala-sbt.org"
      - "repo1.scala-sbt.org"
      - "scala-ci.typesafe.com"
      - "downloads.lightbend.com"
    allowExec:
      - "/usr/bin/java"
      - "/usr/bin/javac"
      - "/usr/bin/jar"
      - "/usr/bin/jshell"
      - "/usr/lib/jvm/"
      - "/usr/bin/mvn"
      - "/usr/share/maven/bin/"
      # GitHub Actions setup-java Temurin installations.
      - "/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/"
      - "~/.sdkman/"
      # Gradle wrapper and daemon execs from here
      - "~/.gradle/"
      # Coursier downloads launchers here
      - "~/.cache/coursier/"
      # Scala / sbt tools
      - "/usr/bin/sbt"
      - "/usr/bin/scala"
      - "/usr/bin/scalac"
      - "/usr/local/bin/sbt"
      - "/usr/local/bin/scala"
      - "/usr/local/bin/scalac"
      - "/usr/share/sbt/"
      # GitHub Actions setup-sbt versioned runner distribution.
      - "/opt/hostedtoolcache/sbt/"
      # Project-local gradlew / mvnw wrapper scripts
      - "$PWD/gradlew"
      - "$PWD/mvnw"
      # Version managers
      - "~/.local/share/mise/"
      - "~/.asdf/"
      - "~/.jenv/"