00-base.sb) provides the foundational layer for all Agent Safehouse policies. It defines the HOME_DIR replacement token, helper macros for path operations, and establishes the default-deny security posture.
Security Model
The Base Profile implements a zero-trust security model with explicit denies:HOME_DIR Replacement Token
Agent Safehouse uses a placeholder token that gets replaced at policy assembly time with the actual user’s home directory:How It Works
- Assembly Time: When
bin/safehouse.shgenerates a policy, it reads00-base.sb - Token Replacement: The
__SAFEHOUSE_REPLACE_ME_WITH_ABSOLUTE_HOME_DIR__placeholder is replaced with the actual home path (e.g.,/Users/alice) - Policy Generation: The resulting policy contains
(define HOME_DIR "/Users/alice")ready for use
This approach allows policies to be user-agnostic until assembly time, making them portable across different systems and users.
Helper Macros
The Base Profile defines three helper macros that other profiles use extensively for path-based permissions:home-subpath
Creates a recursive path matcher starting from a home-relative path:
home-literal
Creates an exact path matcher for a home-relative path:
home-prefix
Creates a prefix matcher that matches paths starting with the given home-relative path:
Path Matcher Comparison
literal
Exact path match onlyExample:
~/.npmrcMatches: ~/.npmrcDoesn’t match: ~/.npmrc.backupprefix
Matches paths starting with prefixExample:
~/.gitconfigMatches: ~/.gitconfig, ~/.gitconfig.localDoesn’t match: ~/.gitsubpath
Recursive directory matchExample:
~/.config/gitMatches: All files under ~/.config/git/Doesn’t match: ~/.config/githubComplete Source
Best Practices
Choose the right matcher for your use case
Choose the right matcher for your use case
- Use
home-literalfor single files:~/.npmrc,~/.gitconfig - Use
home-prefixfor file variants:~/.gitconfig*pattern - Use
home-subpathfor directories:~/.config/git/,~/.npm/
Understand the security implications
Understand the security implications
literalis most restrictive (safest)prefixcan accidentally match more than intendedsubpathgrants recursive access (use carefully)
Test your path matchers
Test your path matchers
Always test that your path matchers work as expected. A common mistake is using
literal when you need prefix, or vice versa.Related Profiles
System Runtime
Core system paths and runtime permissions built on Base Profile helpers
Toolchains
Language-specific profiles using Base Profile macros