The five file tools act with the rights of the process. The authorization
classes say *whether* a tool may run, never *where*: a model with mutate rights
- or a prompt-injected one - could write ~/.ssh/authorized_keys or the config
that names the plugins this harness loads.
core { tools_root = ~/src } closes that. Empty (the default) means no boundary,
so an existing setup is unchanged.
What makes it hold, rather than look like it:
- every path is resolved before it is used, and the resolved path is what the
tool then opens (realpath for existing paths, resolve_target for one that
does not exist yet, so a dangling symlink cannot be followed out);
- search resolves every entry it recurses into: stat() follows a directory
symlink, so guarding only the argument left a door open (found and fixed in
this change, the test went red without it);
- the root is resolved once at startup, and a root that does not exist is
refused with the path in the message instead of matching nothing;
- run cannot be fenced (a shell opens any path); it starts in the root, and a
failed chdir is written into the tool's observation, not the operator's
terminal.
Verified: an escape by absolute path, by ../.., by a symlink inside, by a
dangling symlink, and through search's recursion are all refused in the live
engine path (scripted model, tool call in the session log); the same tree
inside the root still reads; without tools_root everything behaves as before.
Each guard was removed once to watch the test go red. tests: test_builtin,
test_config, test_secrets ok; make check: all tests passed; check_asan: all 46
binaries clean.
2.0 KiB
2.0 KiB
The tool root: what it is and what it is not
The file tools (read, write, edit, search, list) act with the rights of
the splinter process. Without a boundary, a model with mutate rights - or a
prompt-injected one - can write ~/.ssh/authorized_keys, ~/.splinter/splinter.conf
(which names the plugins the harness loads), ~/.bashrc. The authorization
classes say whether a tool may run, never where.
tools_root in core { } closes that:
core {
tools_root = ~/src # empty (the default) = no boundary
}
Rules that make it hold:
- Resolve before deciding, then use the resolved path. A check on one string
and a write to another is the whole class of bug this exists to prevent.
realpath()for existing paths;resolve_target()for a path that does not exist yet, so a dangling symlink inside the root cannot be followed out of it by the write that creates the target. - Recursion needs the same check as the argument.
searchwalks directories;stat()follows a directory symlink. Every entry is resolved before it is opened, otherwise a link inside the root is a door. - The root is resolved once at startup. A symlinked root would make a later comparison lie, and a root that does not exist is refused at startup with the path in the message instead of silently matching nothing.
runis not fenced and cannot be. A shell opens any path it likes. It starts in the root (convenience), and when thatchdirfails the failure goes into the tool's observation - after the redirection, so the model reads it as part of what happened, not on the operator's terminal.- Empty means off. Anything else would be a change to a working setup disguised as a fix.
Tests that guard it live in tests/test_builtin.c (absolute path outside,
../.. walk, symlink inside pointing out, dangling symlink, directory symlink
through search, and the same tree still readable inside the root). Each was
verified by removing the check and watching the test go red.