Lambda Smalltalk provides a sandbox mode for running untrusted scripts securely.
Sandbox Modes
| Mode | Description |
|---|---|
permissive | All operations allowed (default) |
read-only | Only file reads allowed |
restrictive | All 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.stWhat Each Mode Controls
File System
- permissive: Read and write any file
- read-only: Read any file, no writes
- restrictive: No file access
Process Execution
- permissive:
Process run:args:allowed - read-only: Denied
- restrictive: Denied
Network Access
- permissive:
Http get:,Http post:etc. allowed - read-only: Denied
- restrictive: Denied
Plugin Loading
- permissive:
Plugin load:allowed - read-only: Denied
- restrictive: Denied
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.stA 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"