Lambda Smalltalk provides a sandbox mode for running untrusted scripts securely.

Sandbox Modes

ModeDescription
permissiveAll operations allowed (default)
read-onlyOnly file reads allowed
restrictiveAll operations denied

Usage

# Default: all operations allowed
lambda-st run script.st

# Read-only: can read files, but no writes/process/network
lambda-st run --sandbox read-only script.st

# Restrictive: all I/O operations denied
lambda-st run --sandbox restrictive script.st

What Each Mode Controls

File System

Process Execution

Network Access

Plugin Loading

Example: Safe Script Execution

# Run a user-provided script that should only read data
lambda-st run --sandbox read-only user_script.st

# Run a completely isolated script (pure computation only)
lambda-st run --sandbox restrictive compute.st

A denial cannot be caught

When the sandbox denies an operation, the script stops. The denial is reported and the process exits:

sandbox: file_write on 'output.txt': file write access denied by sandbox policy
unhandled exception: sandbox: file_write on 'output.txt': file write access denied by sandbox policy

on:do: does not intercept it — not with Error, not with Exception — and ensure: blocks do not run. This is deliberate: a script you do not trust must not be able to swallow the denial, retry in a loop, or carry on as if the write had happened.

"both handlers are bypassed; the script never reaches 'after'"
[ File write: 'test.txt' content: 'data' ] on: Error do: [:ex | 'caught' displayNl ].
'after' displayNl.

So the caller decides what a denial means, from outside — by the exit status and the message on stderr. Write the host side to expect termination, not a return value.

Ordinary failures are still catchable

A failure that is not a policy decision raises a normal Error, which on:do: handles as usual. Under a permissive sandbox, a missing file is just a missing file:

[ File read: 'nope.txt' ] on: Error do: [:ex | ex messageText displayNl ].
'after' displayNl.   "this runs"