Skip to main content
The palyra-browserd daemon manages the lifecycle of headless Chromium instances, providing a secure, multi-tenant environment for AI agents to perform web automation. Security is enforced through resource budgeting, target URL validation, and artifact quarantine, while state is managed via encrypted profile persistence.

Session Lifecycle Management

Browser sessions are created via the CreateSession gRPC endpoint. Each session is identified by a unique ULID and is associated with a specific principal (the identity of the agent or user) crates/palyra-browserd/src/transport/grpc/service.rs#27-36.

1. Initialization and Provisioning

When a session is initialized, palyra-browserd performs the following steps:

2. Resource Constraints (SessionBudget)

The SessionBudget struct enforces hard limits on the session’s activity to prevent resource exhaustion and data exfiltration crates/palyra-browserd/src/transport/grpc/service.rs#105-165:
  • Timeouts: max_navigation_timeout_ms and max_session_lifetime_ms.
  • Data Limits: max_screenshot_bytes, max_response_bytes, and max_observe_snapshot_bytes.
  • Action Quotas: max_actions_per_session and rate-limiting via max_actions_per_window.
  • Tab Limits: Enforced by DEFAULT_MAX_TABS_PER_SESSION (32) crates/palyra-browserd/src/lib.rs#102-102.

3. Termination and Cleanup

Sessions are terminated when: During termination, palyra-browserd shuts down the Chromium instance, terminates the SOCKS5 proxy, and, if persistence is enabled, encrypts and saves the final session state crates/palyra-browserd/src/transport/grpc/service.rs#73-89.

Security Architecture

Target URL Validation

To prevent agents from accessing internal infrastructure or malicious sites, palyra-browserd implements strict URL validation. The navigate_with_guards function checks targets against:

Download Artifact Quarantine

Downloads are handled through a specialized DownloadSandboxSession crates/palyra-browserd/src/domain/downloads.rs#19-25.

Profile Persistence and Encryption

Browser profiles (cookies, localStorage) are stored using AES-256-GCM encryption.

Engine Integration (Chromium/CDP)

The system uses the headless_chrome crate to interface with Chromium via the Chrome DevTools Protocol (CDP).

Headless Execution

Chromium is launched with a set of security-hardened flags, including --headless, --disable-gpu, and --proxy-server pointing to the session-specific SOCKS5 proxy crates/palyra-browserd/src/engine/chromium.rs#77-89.

Automation Actions

Actions are proxied from gRPC to CDP:

Daemon HTTP Console Proxy

The main palyrad daemon provides an HTTP console that proxies browser actions to palyra-browserd.

Console Handlers

The handlers in palyra-daemon (e.g., console_browser_profiles_list_handler) act as a bridge crates/palyra-daemon/src/transport/http/handlers/console/browser.rs#5-9:
  1. Authorization: Validates the operator’s web session crates/palyra-daemon/src/transport/http/handlers/console/browser.rs#10-10.
  2. Client Building: Constructs a gRPC client for the BrowserService crates/palyra-daemon/src/transport/http/handlers/console/browser.rs#15-15.
  3. Request Transformation: Maps HTTP JSON payloads to browser_v1 protobuf messages crates/palyra-daemon/src/transport/http/handlers/console/browser.rs#16-20.
  4. Audit Logging: Records browser events (e.g., browser.profile.created) to the daemon’s journal crates/palyra-daemon/src/transport/http/handlers/console/browser.rs#70-82.

Data Flow Diagram: Browser Action Execution

The following diagram illustrates the flow from the Web Console through the Daemons to the Chromium engine. Title: Browser Action Flow (Console to CDP) Sources: crates/palyra-daemon/src/transport/http/handlers/console/browser.rs#5-32, crates/palyra-browserd/src/transport/grpc/service.rs#27-50, crates/palyra-browserd/src/engine/chromium.rs#197-210.

Code Entity Map

The following diagram maps high-level concepts to their specific implementations in the codebase. Title: Browser System Code Entity Mapping Sources: crates/palyra-browserd/src/transport/grpc/service.rs#7-12, crates/palyra-browserd/src/transport/grpc/service.rs#105-165, crates/palyra-browserd/src/engine/chromium.rs#70-74, crates/palyra-browserd/src/domain/downloads.rs#19-25.

Summary of Key Constants

ConstantValueDescription
DEFAULT_MAX_TABS_PER_SESSION32Limit on concurrent tabs per session
DOWNLOAD_MAX_FILE_BYTES8 MBMax size for a single download
DOWNLOAD_MAX_TOTAL_BYTES32 MBTotal download quota per session
STATE_KEY_LEN32 bytesLength of the AES-256 encryption key
CLEANUP_INTERVAL_MS15,000Frequency of idle session cleanup
Sources: crates/palyra-browserd/src/lib.rs#82-143.