Blocks direct invocations of policy modification commands:
policies: - name: block-self-modification description: "Prevent AI agents from modifying their own Rampart policy" match: tool: ["exec"] rules: # Substring matching catches ALL shell wrapper bypasses - action: deny when: command_contains: - "rampart allow" - "rampart block" - "rampart rules" - "rampart policy generate" - "rampart init" message: "Policy modification commands must be run by a human, not an agent"
What this blocks:
# Direct invocationrampart allow "curl * | bash"# Absolute path/usr/local/bin/rampart allow "dangerous-command"# Relative path./rampart allow "dangerous-command"# Global flags before subcommandrampart --config custom.yaml allow "dangerous-command"
Substring matching catches attempts to wrap policy commands in shell interpreters:
- action: deny when: command_contains: - "rampart allow" - "rampart block" - "rampart rules" message: "Policy modification commands must be run by a human, not an agent"
Even with self-modification blocking, an agent running as the same user as Rampart can still access config files directly if Rampart crashes or is disabled.
For production deployments, use user separation:
# Create a service accountsudo useradd -r -s /usr/sbin/nologin rampart# Move config to protected locationsudo mkdir -p /etc/rampart /var/lib/rampart/auditsudo cp ~/.rampart/policies/*.yaml /etc/rampart/sudo chown -R rampart:rampart /etc/rampart /var/lib/rampartsudo chmod 700 /etc/rampart /var/lib/rampart/audit# Run serve as the rampart userrampart serve --config /etc/rampart/standard.yaml --audit-dir /var/lib/rampart/audit
With user separation:
Agent cannot read policy files (owned by rampart user)
Agent cannot write to config directories (no permissions)
Agent cannot modify audit logs (separate user ownership)
Agent still works normally — communicates over HTTP on localhost
Test self-modification protection with rampart test:
# Test direct invocationrampart test "rampart allow 'dangerous-command'"# → deny: Policy modification commands must be run by a human# Test shell wrapperrampart test "bash -c 'rampart allow dangerous-command'"# → deny: Policy modification commands must be run by a human# Test shell redirectrampart test "echo permissive > ~/.rampart/policies/custom.yaml"# → deny: Writing to Rampart config directory via shell redirect blocked