Skip to content

Security: benoitpetit/bocal

SECURITY.md

Security policy

Project status

Bocal is an experimental local, single-user prototype. It is not a hosted or multi-tenant service and does not claim conformance to Core Shell. A Linux guest runs as an AArch64 Alpine userland on the Unkernel Linux WebAssembly runtime in a child Node.js process. Security tests demonstrate behavior for the tested image and host; they do not prove that hostile guest code cannot escape the runtime.

The guest has no network stack and receives no host filesystem mount. Optional host-side HTTPS egress is available only through an operator allowlist; DNS and IP checks reject loopback, link-local, private, metadata and IPv6-equivalent targets, redirects are denied and responses are bounded. On Linux, the worker can additionally be launched inside a hardened scope: a dedicated unshare bootstrap creates user, mount, PID, network, UTS and IPC namespaces, hides the operator's home directory, exposes the read-only checkout, the pinned image and the host system paths (/usr, /lib, /lib64, /etc and the Node installation) as read-only binds, mounts a private tmpfs for worker temporaries, and applies file descriptor, process and core-dump rlimits. It then applies no_new_privs and a raw seccomp denylist that kills dangerous syscalls such as ptrace, bpf, keyctl, mount operations, unshare/setns, and clone with CLONE_NEW* flags. clone3 is a deliberate exception: it returns ENOSYS (errno 38) so glibc falls back to clone for thread creation; that fallback is killed if it carries namespace flags. Namespace creation is therefore blocked, but not every clone-family call is killed. When the host provides subordinate UID/GID ranges, the worker runs as the operator's first subordinate identity instead of the operator's own host account. Otherwise the hardened scope is unavailable. Use a low-privilege host account for untrusted workloads.

Linux per-worker systemd resource limits are applied only when a real manager probe succeeds. The active profile is MemoryMax=1024M, MemorySwapMax=0, CPUQuota=100%, and TasksMax=128; auto mode warns and continues without those host quotas if the manager is unavailable. A separate local systemd test observed those controls. The MCP benchmark process did not receive them; its report marks host quotas unavailable. These cgroups are resource controls, not a host security boundary.

Host isolation modes

The operator config also controls max_concurrent_jobs (1 or 2) and allow_agent_terminal (default false). Agent terminal tools are disabled unless explicitly enabled; they give the MCP client an interactive shell inside the guest and must be treated as a high-privilege capability.

The operator config field host_isolation accepts:

  • "best-effort" (default): use the hardened worker scope when the host probe accepts it; otherwise continue with cgroup limits only.
  • "required": fail closed before starting a worker if Linux namespaces, systemd cgroup controls or the probe are unavailable.
  • "disabled": keep the legacy worker launch with cgroup limits only.

bocal doctor reports the effective mode, any AppArmor/SELinux confinement and sandbox_capabilities returns the isolation mode. Sandbox metadata is journaled in a private 0600 file under the data directory; after a daemon restart, non-destroyed sandboxes are restored as inert failed tombstones instead of being silently forgotten. A SIGKILL of a cgroup-controlled worker is reported as the structured worker.resource_limit event. An AppArmor profile template is shipped in packages/cli/resources/apparmor/bocal-worker; it must be adapted to the local Node path and checkout before installation. The real-guest check is pnpm test:host-isolation:real and the seccomp boundary by pnpm test:seccomp:real; both report NOT_RUN when the host cannot provide the hardened scope.

Privileged guest modes

Three optional modes are disabled by default and must be enabled one by one in the operator config. Each one also requires the matching capability in allowed_capabilities; a flag alone never activates it, and an agent cannot enable any of them through MCP.

  • allow_packages (package.install) downloads a pinned .apk from an HTTPS directory allowlist, checks its SHA-256, extracts only safe regular files into /workspace/.pkgs, and never writes to guest system directories. The guest keeps UID 1000 and has no network.
  • allow_guest_root (shell.root) lets a single sandbox_exec run as guest UID 0. This is weakened isolation inside the guest only: the Bocal host process still refuses to run as root, the job stays in its cgroup and keeps the timeout, output and stop-evidence limits. Guest root can read any guest path, including .bocal-control, but file transfers and jobs share the same single active lease, so staging is empty while a root job runs and no in-flight transfer data can be stolen. The CLI requires --root --yes and emits a warning on stderr.
  • allow_tunnel (network.tunnel) adds a bounded HTTPS request proxy with its own origin allowlist and request budget. The guest still has no network stack; only the host proxy performs DNS and HTTP, with the same SSRF checks as the existing allowlist proxy. A guest helper bocal-net GET|HEAD <url> can request a response through the guest agent, which relays it over GSP and IPC to that same host proxy. Only one guest request may be in flight; the body is capped and the allowlist never leaves the host.

bocal doctor reports each mode as warning when enabled and ok otherwise. sandbox_capabilities lists the effective capabilities. The daemon records a fingerprint of the operator config and restarts when it changes, so a previous set of security flags cannot stay active silently.

Supported versions

Bocal is publicly released and installable with npm install --global bocal. Every image release matches the pinned manifest and includes its corresponding-source materials. The product version (PRODUCT_VERSION), the pinned Unkernel runtime version (UNKERNEL_RUNTIME_VERSION) and the kernel dependency pin (KERNEL_DEPENDENCY_PIN) are published as single constants in @bocal/protocol; the internal @bocal/runtime-unkernel package carries its own package version. Other host architectures and operating systems are not verified.

Reporting a vulnerability

GitHub private vulnerability reporting is the intended channel on the public repository. No alternate security email has been designated. Please do not put sensitive vulnerability details in a public issue.

Current limits

  • Bocal is not hardened for multi-tenant or hostile-code workloads.
  • Resource quotas are host-dependent. They are reported as active only after systemd confirms the worker scope; other host platforms are untested.
  • The worker uses a subordinate host identity only when /etc/subuid and /etc/subgid ranges exist; Linux namespaces and the seccomp denylist are best-effort and still not a certified boundary.
  • Guest egress denial, bounded workspace behavior, cancellation and cleanup have real-guest tests, but tests cannot rule out runtime escapes.
  • Every published image release includes its corresponding-source archive, notices, SBOM, and checksums. Their integrity checks are engineering evidence, not a legal opinion. The separate Unkernel npm runtime scope is not covered by this image package; see docs/licenses/unkernel/THIRD-PARTY.md.

There aren't any published security advisories