Multi-Tier Sandboxing Architecture
The system categorizes tool execution into three tiers of isolation, depending on the required capabilities and the host platform’s support.| Tier | Name | Technology | Isolation Level |
|---|---|---|---|
| Tier-A | WASM Runtime | wasmtime | Full instruction-level sandboxing; capability-based security for host imports. |
| Tier-B | In-Process Unix | std::process + Unix Controls | Basic process isolation with OS-level resource limits (CPU/Memory) on Unix systems. |
| Tier-C | OS-Level Sandbox | bwrap (Linux) / sandbox-exec (macOS) | Strong namespace isolation, filesystem remapping, and network unsharing. |
Tier-C Backend Dispatch
Thepalyra-sandbox crate provides a unified interface for platform-specific Tier-C backends. It detects the host OS and selects the appropriate executor: LinuxBubblewrap, MacosSandboxExec, or WindowsJobObject crates/palyra-sandbox/src/lib.rs#8-13.
Diagram: Sandbox Backend Selection and Command Planning
The TierCBackend trait abstracts the complexity of constructing sandboxed command lines across different operating systems.
Sources: crates/palyra-daemon/src/sandbox_runner.rs#147-210, crates/palyra-sandbox/src/lib.rs#81-91, crates/palyra-sandbox/src/lib.rs#107-184
Tool Approval Lifecycle
Before a tool is executed, it must pass through a security pipeline that evaluates theToolProposal. This process checks if the tool is allowlisted, if it requires human approval, and if it has exceeded its execution budget.
- Proposal Evaluation: The
evaluate_tool_proposal_securityfunction determines if the tool is “sensitive” based on its capabilities (e.g.,ProcessExec,Network) crates/palyra-daemon/src/tool_protocol.rs#47-52, crates/palyra-daemon/src/application/run_stream/tool_flow.rs#121-134. - Approval Resolution: If approval is required, the system first checks the cache via
resolve_cached_tool_approval_for_proposalcrates/palyra-daemon/src/application/approvals/mod.rs#67-76. - Human-in-the-Loop: If no valid cached approval exists, a
PendingToolApprovalis created and sent to the user via theRunStreamcrates/palyra-daemon/src/application/approvals/mod.rs#100-135. - Decision Enforcement: The
apply_tool_approval_outcomefunction merges the user’s decision into the finalToolDecisioncrates/palyra-daemon/src/application/approvals/mod.rs#32-64.
Cedar Policy Evaluation
Palyra uses the Cedar policy language for fine-grained authorization. Policies are evaluated withinpalyra-policy using a PolicyRequestContext that includes details like device_id, run_id, and requested capabilities crates/palyra-policy/src/lib.rs#17-26.
Default Policy Logic
The system enforces several baseline rules defined inDEFAULT_POLICY_SRC crates/palyra-policy/src/lib.rs#99-187:
- Forbid Sensitive: Blocks actions where
context.is_sensitive_actionis true unlessallow_sensitive_toolsis explicitly granted crates/palyra-policy/src/lib.rs#100-105. - Permit Allowlisted: Allows
tool.executeif the tool name is in the allowlist and the principal/channel are authorized crates/palyra-policy/src/lib.rs#120-127. - Read-Only Access: Permits common status and health checks by default crates/palyra-policy/src/lib.rs#107-118.
Egress Enforcement Modes
Network access for tools (especially in Tier-C) is controlled byEgressEnforcementMode crates/palyra-daemon/src/sandbox_runner.rs#47-51:
- None: No network restrictions applied.
- Preflight: Requested hosts are checked against an allowlist before the process starts, but the sandbox does not enforce host-level blocking at runtime.
- Strict: The sandbox enforces network isolation (e.g.,
bwrap --unshare-net) and only allows traffic to specific hosts if the backend supports it crates/palyra-daemon/src/sandbox_runner.rs#186-194.
allowed_egress_hosts policy, the execution is denied with SandboxProcessRunErrorKind::EgressDenied crates/palyra-daemon/src/sandbox_runner.rs#112.
Sources: crates/palyra-daemon/src/sandbox_runner.rs#80-93, crates/palyra-sandbox/src/lib.rs#37-44
Execution Attestation
Every tool execution generates aToolAttestation which is recorded in the run’s journal. This provides a cryptographic and metadata-rich audit trail of what happened inside the sandbox.
| Field | Description |
|---|---|
attestation_id | Unique identifier for the execution event. |
execution_sha256 | SHA256 hash of the tool’s output crates/palyra-daemon/src/tool_protocol.rs#75. |
executor | The name of the runner used (e.g., sandbox_tier_c_linux_bubblewrap) crates/palyra-daemon/src/tool_protocol.rs#78. |
sandbox_enforcement | Description of the enforcement level applied (e.g., “strict”) crates/palyra-daemon/src/tool_protocol.rs#79. |
RunStream using send_tool_attestation_with_tape to ensure the UI can display the security posture of the result crates/palyra-daemon/src/application/run_stream/tool_flow.rs#40.
Sources: crates/palyra-daemon/src/tool_protocol.rs#73-80, crates/palyra-daemon/src/sandbox_runner.rs#120-126