HTTP service that executes untrusted user-supplied transform scripts in a sandboxed environment. Each request provides code and JSON input; the service runs the code and returns JSON output.
- Request arrives with
language,code,input(JSON), and optionaltimeout - Code is written to a temp directory alongside an embedded harness script
- Harness is executed inside a bubblewrap sandbox — new user/PID/IPC/UTS namespaces, UID 65534 (nobody), read-only filesystem mounts,
ulimit -vmemory cap - Harness loads the user's
run()function, passesinputvia stdin, and writes the return value as JSON to stdout - Output is validated as a JSON object and returned to the caller
| Language | Runtime |
|---|---|
python |
python3 |
node |
txiki.js (tjs) |
php |
php83 |
{
"language": "python",
"code": "def run(input):\n return {'doubled': input['value'] * 2}",
"input": {"value": 5},
"timeout": 10
}Response 200
{"output": {"doubled": 10}}Response 400 — invalid request or unsupported language
Response 422 — runtime error, timeout, non-zero exit, or non-object output
Returns 200 OK.
Each language expects a run function that accepts the input object and returns a JSON-serializable object. console.log / print / echo goes to stderr (visible in server logs, not in the response).
Python
def run(input):
return {"result": input["value"] * 2}Node (ESM or CJS export)
export function run(input) {
return { result: input.value * 2 };
}PHP (<?php tag is optional — stripped automatically)
<?php
function run($input) {
return ["result" => $input["value"] * 2];
}| Env var | Default | Description |
|---|---|---|
PORT |
3000 |
Listen port |
TRANSFORM_TIMEOUT |
30 |
Max execution seconds (cap applied per-request) |
TRANSFORM_MEMORY_LIMIT |
134217728 |
Virtual memory limit in bytes (128 MB) |
Docker Compose
docker compose upBuild image manually
docker build -t transform-runner .
docker run -p 3000:3000 --security-opt seccomp=unconfined transform-runner
seccomp=unconfinedis required for bubblewrap's user namespace sandboxing to work inside Docker.
Local (sandbox tests require bwrap on PATH)
go test ./...
go run .