librampart.so preloaded, intercepting execve, execvp, system(), popen(), and posix_spawn() at the OS level.
Usage
-- separator before the command.
How it works
Linux: SetsLD_PRELOAD=~/.rampart/lib/librampart.so
macOS: Sets DYLD_INSERT_LIBRARIES=~/.rampart/lib/librampart.dylib
The library intercepts exec-family syscalls:
execve()- Execute programexecvp()- Execute program (search PATH)execvpe()- Execute program with environmentsystem()- Execute shell commandpopen()- Open process pipeposix_spawn()- Spawn process
- Extracts command from syscall arguments
- Sends to Rampart HTTP API for evaluation
- Returns
EPERMif denied - Proceeds if allowed
Flags
Port for rampart serve (must match
rampart serve --port)Auth token (or set
RAMPART_TOKEN)Mode:
enforce, monitor, or disabledAllow commands if Rampart is unreachable (fail-safe mode)
Agent name for audit events
Session ID for audit (default:
preload-{pid})Enable debug logging in the library
Examples
Protect Codex CLI
Protect any Python agent
Protect Node.js agent
Monitor mode
Fail-closed mode
Library installation
Build from source:Platform support
Linux
Coverage: ~95% of dynamically-linked binaries Works with:- Binaries from package managers (apt, yum, pacman)
- Binaries installed via pip, npm, cargo, go install
- Most scripting languages (Python, Node.js, Ruby, Perl)
- Statically-linked binaries (Go binaries compiled without CGO)
- Binaries that explicitly clear
LD_PRELOAD
macOS
Coverage: Works with most user-installed binaries Works with:- Homebrew binaries
- nvm/Node.js
- pyenv/Python
- rbenv/Ruby
- cargo/Rust binaries
/usr/bin/*- macOS System Integrity Protection blocks preload/bin/*- SIP-protected/sbin/*- SIP-protected
Windows
Not supported. Userampart wrap instead.
Output
Startup
Blocked command
Debug mode
Environment variables
The library reads these variables:Rampart serve API URL
Bearer token for API authentication
Mode:
enforce, monitor, or disabled1 = allow if Rampart unreachable, 0 = denyAgent name for audit events
Session ID for audit
1 = enable debug logging to stderrCascade protection
Preload protects subprocess trees:LD_PRELOAD is inherited.
Performance
Per-command overhead:- Policy check: 4μs
- HTTP call (localhost): less than 1ms
- Total: ~1ms per command
- Intel i7, Linux 6.x, localhost HTTP
- Invisible latency for normal agent workflows
Compatibility with other tools
Go binaries
CGO-enabled: Works ✅ Static (default Go build): Doesn’t work ❌ Fix:Docker
Inside container: Works if librampart is mountedRust/Cargo
Dynamic linking (default): Works ✅Python
Works ✅ (Python is dynamically linked)Node.js
Works ✅ (Node.js is dynamically linked)Troubleshooting
”librampart.so not found”
Check library exists:Commands still bypassing
Check if binary is static:macOS: “Operation not permitted”
SIP is blocking preload:rampart wrap or install binary outside SIP-protected locations.
Serve not reachable
Check serve is running:Exit codes
0- Command exited successfully126- Command was blocked by policy1- Operation not permitted (EPERM from denied syscall)- Other - Command’s actual exit code
See also
- rampart wrap - Shell-based wrapping
- rampart setup - Native agent hooks
- Preload README - Build instructions