gbash

Security Model

gbash is a deterministic, sandbox-only bash runtime. Every session runs inside a constrained environment where the shell can only see what you explicitly provide.

Isolation by default

When you create a gbash runtime, the shell operates against a virtual filesystem -- by default an in-memory filesystem with no access to the host. Commands resolve through a registry, not the host PATH. If a command is not registered, it fails with exit code 127. Host binaries never execute.

rt := gbash.New() // memory FS, no network, no host commands

Network

Network access is off by default. When you enable it with WithHTTPAccess, WithNetwork, or a custom network client, gbash registers curl. The built-in client constrains requests through URL-prefix allowlists, method allowlists, redirect revalidation, optional private-range blocking, and response-size caps. Without any network configuration, curl is not available and all egress is denied.

Execution budgets

Every execution is bounded by configurable limits that prevent runaway scripts:

BudgetDefaultWhat it limits
MaxCommandCount10,000Total commands per execution
MaxLoopIterations10,000Iterations in any single loop
MaxGlobOperations100,000Glob expansion operations
MaxSubstitutionDepth50Nested command/arithmetic substitution depth
MaxStdoutBytes1 MBStdout before truncation
MaxStderrBytes1 MBStderr before truncation
MaxFileBytes8 MBMaximum file size

Observability

Tracing is opt-in. When enabled, gbash can emit structured execution events covering command starts and exits, file access and mutation, and policy denials. Redacted tracing is the recommended mode for shared systems, and lifecycle logging is available through a separate callback API. See Tracing and Logging for details.

What gbash is not

gbash provides application-level sandboxing. It is not a hardened OS-level sandbox. For stronger containment guarantees, run gbash inside a container, VM, or other OS-level isolation mechanism. See the threat model for a full discussion of risks and mitigations.