Skip to main content
Palyra employs a multi-tier sandbox architecture designed to provide defense-in-depth for executing untrusted code and system processes. The system balances strict isolation with the practical needs of an AI agent, such as workspace access and controlled network egress.

Sandbox Tier Architecture

The execution environment is divided into three tiers, each offering different levels of isolation and resource control.
TierTechnologyUse CasePrimary Enforcement
Tier-AWebAssembly (Wasmtime)Skill PluginsFuel budgets, memory linear isolation, WIT-based capability grants.
Tier-BOS rlimit (Unix)Basic Tool ExecutionProcess-level resource limits (CPU, Memory) on standard Unix processes.
Tier-Cbwrap / sandbox-execHardened ExecutionNamespace isolation (Linux) or Seatbelt profiles (macOS) with filesystem re-rooting.

Tier-A: WASM Plugin Runtime

WASM execution is handled by the palyra-plugins-runtime crate, utilizing wasmtime with strict capability-based security.

Tier-B & Tier-C: Process Execution

Native process execution is managed by the sandbox_runner.rs in the daemon. Sources: crates/palyra-plugins/runtime/src/lib.rs#1-110, crates/palyra-daemon/src/sandbox_runner.rs#64-78, crates/palyra-sandbox/src/lib.rs#7-35

Validation Pipeline & Egress Enforcement

Before any process is spawned, it must pass through a multi-stage validation pipeline defined in run_constrained_process crates/palyra-daemon/src/sandbox_runner.rs#147-209.

1. Input Validation

The runner parses ProcessRunnerToolInput and enforces strict constraints on the command shape:

2. Workspace Scoping

The system ensures that the command and all its arguments are scoped within the workspace_root.

3. Egress Enforcement Modes

Palyra implements three levels of network egress control crates/palyra-daemon/src/sandbox_runner.rs#46-62:
  • None: No network restrictions.
  • Preflight: Checks requested hosts against an allowlist before execution but does not enforce at the kernel level.
  • Strict: Requires kernel-level enforcement (e.g., unshare-net in bwrap). If the backend cannot enforce this, execution is denied crates/palyra-daemon/src/sandbox_runner.rs#192-194.
Sources: crates/palyra-daemon/src/sandbox_runner.rs#147-230, crates/palyra-sandbox/src/lib.rs#176-178

Execution & Output Capture

Process Lifecycle Flow

The following diagram illustrates the flow from a ToolCall to actual process execution via the SandboxProcessRunner. Title: Tool Execution Logic Flow Sources: crates/palyra-daemon/src/sandbox_runner.rs#147-209, crates/palyra-daemon/src/tool_protocol.rs#13-16, crates/palyra-sandbox/src/lib.rs#86-91

Output Capture and Quotas

The daemon captures stdout and stderr using StreamCapture crates/palyra-daemon/src/sandbox_runner.rs#141-145.

Attestation & Security Metadata

Every tool execution generates a ToolAttestation which is stored in the ToolExecutionOutcome crates/palyra-daemon/src/tool_protocol.rs#83-88. This provides an audit trail of how the code was executed. ToolAttestation Fields:

Code Entity Mapping

The following diagram maps high-level security concepts to specific Rust structs and functions. Title: Sandbox Entity Mapping Sources: crates/palyra-daemon/src/sandbox_runner.rs#81-93, crates/palyra-sandbox/src/lib.rs#53-57, crates/palyra-daemon/src/tool_protocol.rs#73-80, crates/palyra-daemon/src/wasm_plugin_runner.rs#18-30

Tier-C Implementation Details

The palyra-sandbox crate abstracts the platform-specific complexities of Tier-C execution.

Linux (Bubblewrap)

The LinuxBubblewrapBackend builds a command plan that:
  1. Clears the environment (--clearenv) crates/palyra-sandbox/src/lib.rs#165.
  2. Mounts a minimal /proc, /dev, and /tmp crates/palyra-sandbox/src/lib.rs#133-141.
  3. Bind-mounts essential system libraries (e.g., /usr, /lib) as read-only crates/palyra-sandbox/src/lib.rs#145-147.
  4. Bind-mounts the workspace_root as the only writable area crates/palyra-sandbox/src/lib.rs#159-162.
  5. Optionally unshares the network stack (--unshare-net) for isolation crates/palyra-sandbox/src/lib.rs#176-178.

macOS (sandbox-exec)

Uses the native Seatbelt framework. It generates temporary profiles that restrict filesystem access to the workspace and block network sockets based on the TierCPolicy crates/palyra-sandbox/src/lib.rs#10-20. Sources: crates/palyra-sandbox/src/lib.rs#81-184