@draht/rlm 2026.7.12-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,89 @@
1
+ ;; macOS `sandbox-exec` (Seatbelt/SBPL) profile for the RLM Python REPL driver.
2
+ ;;
3
+ ;; This is the REAL security boundary described in
4
+ ;; .planning/phases/28-repl-sandbox-safety/28-01-PLAN.md, Architecture
5
+ ;; section 1 -- NOT the Python-level guardrails in repl_driver.py (those are
6
+ ;; defense-in-depth for a confused/prompt-injected LLM, not the thing that
7
+ ;; stops a deliberately adversarial payload; see the plan's "IMPORTANT"
8
+ ;; section for why in-process restriction of arbitrary Python cannot work).
9
+ ;;
10
+ ;; Deny-by-default: no network, no spawning other processes (which alone
11
+ ;; defeats os.system/subprocess -- they fork+exec a shell -- independent of
12
+ ;; any Python-level import block), and file access scoped to exactly the
13
+ ;; Python installation needed to boot the interpreter plus the caller's
14
+ ;; session workdir.
15
+ ;;
16
+ ;; Machine-specific paths (where python3 actually lives, and the session's
17
+ ;; workdir) are NOT hardcoded here -- they're discovered at spawn time by
18
+ ;; ../src/sandbox.ts and injected as `-D NAME=value` sandbox-exec params,
19
+ ;; read back here via `(param "NAME")`. This file only encodes the *policy*.
20
+ ;;
21
+ ;; Params (all supplied by sandbox.ts, see buildMacosSandboxArgs):
22
+ ;; PYTHON_REAL_BIN - realpath of the python3 interpreter binary to run.
23
+ ;; PYTHON_REEXEC_BIN - a second binary some Python builds (notably macOS
24
+ ;; framework builds, e.g. Homebrew's --with-framework)
25
+ ;; internally posix_spawn() themselves into at startup
26
+ ;; (to run as a proper .app bundle, e.g. for Tk/Cocoa
27
+ ;; access) before ever reaching user code. When a
28
+ ;; build doesn't do this, sandbox.ts passes the same
29
+ ;; value as PYTHON_REAL_BIN here (a harmless no-op
30
+ ;; duplicate rule).
31
+ ;; PYTHON_PREFIX - realpath of sys.prefix -- the stdlib/interpreter
32
+ ;; installation root that must be readable to boot.
33
+ ;; DRIVER_PATH - absolute path to repl_driver.py.
34
+ ;; WORKDIR - the session's scratch directory; the only place
35
+ ;; Python-executed code may read *and* write freely.
36
+
37
+ (version 1)
38
+
39
+ (debug deny)
40
+
41
+ (deny default)
42
+
43
+ ;; Baseline rules every process needs from dyld to even get past process
44
+ ;; startup (shared-cache mapping, cryptex graft points, etc.) -- see
45
+ ;; /System/Library/Sandbox/Profiles/dyld-support.sb. Without this, dyld
46
+ ;; itself aborts (SIGABRT) before main() ever runs, regardless of any file
47
+ ;; rule below -- confirmed empirically while scoping this profile.
48
+ (import "dyld-support.sb")
49
+
50
+ ;; No network access whatsoever -- covers `urllib.request.urlopen(...)`,
51
+ ;; raw sockets, DNS resolution, everything.
52
+ (deny network*)
53
+
54
+ ;; No spawning of other processes. This is what actually defeats
55
+ ;; `os.system(...)`/`subprocess.*` (they fork+exec a shell) -- independent
56
+ ;; of whatever `repl_driver.py`'s Python-level import allowlist does or
57
+ ;; doesn't block.
58
+ (deny process-exec*)
59
+
60
+ ;; The one process-exec sandbox-exec itself needs to perform: launching the
61
+ ;; Python interpreter (and, on framework builds, its internal re-exec hop).
62
+ (allow process-exec (literal (param "PYTHON_REAL_BIN")))
63
+ (allow process-exec (literal (param "PYTHON_REEXEC_BIN")))
64
+
65
+ ;; Allow traversing symlinks / stat'ing paths in general -- matches the
66
+ ;; stock bsd.sb baseline and is required for ordinary interpreter startup
67
+ ;; (module path resolution, etc.); it does not grant reading file *content*.
68
+ (allow file-read-metadata)
69
+
70
+ ;; Read access to the Python installation itself (stdlib .py/.so files,
71
+ ;; encodings data, etc.) and the handful of standard OS library locations
72
+ ;; every macOS process needs to link against libSystem/Foundation/etc.
73
+ ;; These OS paths are fixed (present identically on every Mac) -- only the
74
+ ;; Python installation's own location is machine-specific and therefore
75
+ ;; passed in as a param rather than guessed.
76
+ (allow file-read* (subpath (param "PYTHON_PREFIX")))
77
+ (allow file-read* (subpath "/usr/lib"))
78
+ (allow file-read* (subpath "/usr/share"))
79
+ (allow file-read* (subpath "/System/Library"))
80
+ (allow file-read* (literal "/dev/null"))
81
+ (allow file-read* (literal "/dev/urandom"))
82
+
83
+ ;; The driver script itself (it lives in this repo, not the Python install).
84
+ (allow file-read* (literal (param "DRIVER_PATH")))
85
+
86
+ ;; The session workdir: the only place executed code may read *and* write
87
+ ;; freely. Nothing outside of this, the Python installation above, and the
88
+ ;; driver script is readable, and nothing outside this is writable at all.
89
+ (allow file-read* file-write* (subpath (param "WORKDIR")))