This demo shows a small chat-style Python evaluator running inside the GraalPy GraalOS standalone.
The story:
richrenders a friendly terminal UI.- The demo treats each entered expression as untrusted Python code, such as code produced by an LLM agent or pasted by a human operator.
- The process is inside the GraalOS sandbox, so file, subprocess, network, and native library attempts remain contained.
We can install the rich wheel directly into the standalone's site-packages
using any standard Python. While we could run ensurepip and pip inside the
sandbox by configuring the appropriate network access, we do this here
intentionally done outside the sandbox. The sandboxed standalone has no
outbound network mapping by default, which is one of the things the demo can
show.
python3 -m pip install \
--target GRAALPY_NATIVE_GRAALOS_STANDALONE/lib/python3.12/site-packages \
--only-binary=:all: \
--python-version 3.12 \
--implementation py --implementation graalpy \
--abi none --abi graalpy250_312_native \
--platform any --platform graalos_x86_64 \
--no-compile \
richThere should be a file test_graalos_sandbox_chat.py in this directory. If
not, find it in and copy it from the GraalPy source repository. From inside the
sandbox that file is available as /test_graalos_sandbox_chat.py, so run:
./bin/graalpy /test_graalos_sandbox_chat.pyFor a non-interactive walkthrough:
./bin/graalpy /test_graalos_sandbox_chat.py --demoStart with a normal expression:
sum([i*i for i in range(1000)])Then move on to untrusted code that tries to access host resources:
open('/etc/passwd').read()
open('/etc/passwd').read().splitlines()[:3]
open('/etc/shadow').read()
__import__('subprocess').run(['/bin/sh', '-c', 'id'], capture_output=True, text=True)
__import__('socket').create_connection(('example.com', 80), timeout=2)
__import__('ctypes').CDLL('libc.so').system(b'cat /etc/shadow')Expected result: harmless operations work or fail normally; sensitive host
resources are unavailable because the process only sees the sandboxed virtual
filesystem, process namespace, and configured network policy. The native
system() probe returns -1, which the demo renders as blocked.
This is a deliberately unsafe application pattern: it evaluates untrusted Python code directly. That is useful for demonstrating the actual containment boundary. GraalOS is that boundary, and it mediates filesystem, subprocess, native, and network behavior even when the application itself offers no extra guardrails.