Skip to main content
This page documents the persistence mechanisms and security boundaries of palyra-browserd. It covers how browser sessions are saved and restored across restarts, the multi-tenant profile registry, cryptographic isolation of session data, and the safety measures applied to browser-generated artifacts.

Browser Profile Registry and Persistence

palyra-browserd manages a registry of browser profiles, each representing a distinct set of user data (cookies, local storage, history). These profiles are persisted in an encrypted registry file, ensuring that sensitive session metadata is never stored in plaintext on disk.

BrowserProfileRegistryDocument

The registry is managed via the BrowserProfileRegistryDocument, which tracks profiles associated with specific principals.

PersistedStateStore

The PersistedStateStore handles the low-level serialization and encryption of session snapshots. When a session is created with persistence_enabled=true, the browser engine’s state is periodically snapshotted and saved crates/palyra-browserd/src/transport/grpc/service.rs#51-58.

Data Flow: Profile and State Persistence

The following diagram illustrates how a profile is resolved and its state is loaded from the encrypted store. Browser State Resolution Flow Sources: crates/palyra-browserd/src/transport/grpc/service.rs#29-91, crates/palyra-browserd/src/lib.rs#131-145, crates/palyra-identity/src/store.rs#20-31

Per-Profile Derived Encryption Keys

Security is enforced by deriving unique encryption keys for every profile. This prevents a compromise of one profile’s data from affecting others. Sources: crates/palyra-browserd/src/lib.rs#131-135, crates/palyra-identity/src/store.rs#16-23, crates/palyra-browserd/src/support/tests.rs#1-17

Download Artifact Quarantine

To prevent malicious files from reaching the host system directly, palyra-browserd implements a multi-stage download handling process involving sandboxing and quarantine.

DownloadSandboxSession

Every browser session that allows downloads is assigned a DownloadSandboxSession. This creates a temporary directory structure to isolate files crates/palyra-browserd/src/domain/downloads.rs#20-25.

Validation Logic

Files are quarantined based on two primary criteria:
  1. Extension Allowlist: Only safe extensions (e.g., .txt, .pdf, .json) are permitted crates/palyra-browserd/src/lib.rs#153-153.
  2. MIME Type Validation: The Content-Type must match a set of known-safe types crates/palyra-browserd/src/lib.rs#154-162.
If a file fails these checks, it is moved to the quarantine directory with a quarantine_reason (e.g., extension_not_allowlisted) crates/palyra-browserd/src/domain/downloads.rs#105-118.
ConstraintDefault ValueSource
Max File Size8 MBcrates/palyra-browserd/src/lib.rs#148-148
Max Session Storage32 MBcrates/palyra-browserd/src/lib.rs#147-147
Max Artifacts128crates/palyra-browserd/src/lib.rs#149-149
Sources: crates/palyra-browserd/src/domain/downloads.rs#1-173, crates/palyra-browserd/src/lib.rs#147-162

CLI Browser Commands

The palyra CLI provides a suite of commands to interact with the browser daemon. These commands translate user intent into gRPC calls to palyra-browserd.

Core Commands and Functions

CLI CommandInternal FunctionPurpose
palyra browser consolerun_browser_consoleOpens an interactive REPL or executes JS in the session.
palyra browser highlightrun_browser_highlightVisually highlights elements matching a CSS selector.
palyra browser selectrun_browser_selectReturns the text or attributes of specific DOM elements.
palyra browser pdfrun_browser_pdfGenerates a PDF print-out of the current page.
palyra browser tracerun_browser_traceCaptures network and console logs for the session.

Implementation Detail: Browser Action Lifecycle

The CLI uses the BrowserServiceImpl gRPC client to communicate with the daemon. Most actions follow a pattern of resolving the session, performing a blocking Chromium operation, and returning the result as JSON or text. CLI to Code Entity Mapping Sources: crates/palyra-cli/src/commands/browser.rs#160-240, crates/palyra-browserd/src/transport/grpc/service.rs#13-32, crates/palyra-browserd/src/engine/chromium.rs#60-68

Output Modes

The CLI supports multiple output formats via the --output or --json flags: Sources: crates/palyra-cli/src/commands/browser.rs#1-240, crates/palyra-cli/src/args/browser.rs#1-22