Beamtalk Security Model

This document describes the security design of the Beamtalk runtime, focusing on the REPL WebSocket server and workspace management. Beamtalk has no separate compiler daemon: inside a workspace the compiler is an OTP Port owned by the BEAM node (see architecture), and batch commands run the compiler in-process.

Overview

Beamtalk follows a localhost-only by default security model. The REPL server and workspace are designed for local development and bind to the loopback interface. Connections are authenticated with the workspace's Erlang cookie, and browser-originated connections are checked against loopback Origin/Host rules (below).

This is the same trust model as erl (the Erlang shell), iex (Elixir), irb (Ruby), and node (Node.js): anything that can reach the REPL and holds the cookie can run arbitrary code.

Components

REPL WebSocket Server

The REPL server (beamtalk_repl_server) is a cowboy WebSocket listener (ADR 0020). By default it binds the IPv4 loopback address 127.0.0.1; beamtalk repl --bind <addr> changes that (an IP address, 0.0.0.0, or tailscale). A non-loopback --bind prints a safety warning (--confirm-network suppresses that one) and always prints a warning that the ws:// transport is unencrypted, so the cookie and all evaluated code cross the network in cleartext. Use it only on a network you trust (e.g. Tailscale).

socket_opts => [{ip, BindAddr}, {port, Port}]

Security properties:

MCP server

The MCP server's file-based tools (lint, diagnostic_summary, load_file, load_project, test on a file, export_traces) are confined to the project root; symlinks and .. components are resolved before the check. The server refuses to start confined to the filesystem root, the user's home directory (HOME on Unix, the profile folder on Windows) or any directory containing it, such as /home. --allow-outside-project removes the confinement. Every MCP tool declares readOnlyHint, and every non-read-only tool a destructiveHint.

LiveView IDE front

The LiveView front binds loopback by default (BT_ATTACH_BIND_IP unset). A non-loopback bind with no authentication gate (OIDC or dev-auth) is refused at boot; set BT_IDE_ALLOW_UNAUTHENTICATED=1 to opt in explicitly. See remote LiveView IDE.

Workspace Isolation

Each workspace stores persistent state under ~/.beamtalk/workspaces/<workspace_id>/ (or under $BEAMTALK_HOME when set), in directories created with mode 0700:

~/.beamtalk/workspaces/<workspace_id>/metadata.json   # Project path, loaded modules
~/.beamtalk/workspaces/<workspace_id>/cookie           # Erlang distribution cookie

Workspace metadata is scoped to its project.

Threat Model

In Scope

ThreatMitigation
Remote network access to REPLLoopback binding (127.0.0.1) prevents remote connections
Cross-site WebSocket hijacking / DNS rebinding from a browserOrigin and Host must be loopback (or the bound address); cookie required
Unauthenticated connections tying up the server10 s auth deadline, 4 KiB pre-auth frame limit, a separate 32-socket pre-auth budget in which a new socket evicts the oldest unauthenticated one, 256 authenticated-connection cap
Cross-user access to workspace statePer-workspace directories created with mode 0700

Out of Scope (Current)

ThreatStatus
Local privilege escalationTrusted local environment (same as erl, iex)
Malicious local processesNot mitigated (standard for development tools)
Code injection via REPL protocolREPL executes arbitrary code by design

Remote access

Remote REPL access is opt-in through beamtalk repl --bind; it is never the default. The WebSocket transport is not encrypted, so for anything beyond a trusted private network use the authenticated LiveView front (remote LiveView IDE, ADR 0091) instead of exposing the REPL port.

References