Install
openclaw skills install canary-srSafety monitoring and tripwire detection for AI agents. Protects against unauthorized file access, dangerous commands, and excessive activity. Auto-halts on...
openclaw skills install canary-srSafety monitoring and tripwire detection for AI agents. Protects against unauthorized file access, dangerous commands, and excessive activity. Auto-halts on critical violations. Honeypot tripwires detect snooping.
Safety monitoring and tripwire detection for AI agents.
Protects against unauthorized file access, dangerous commands, and excessive activity. Auto-halts on critical violations. Honeypot tripwires detect snooping.
Canary provides three layers of agent safety:
Protected Paths:
/etc/, ~/.ssh/, etc.)Forbidden Patterns:
rm -rf /, chmod 777, curl | sh, etc.Rate Limiting:
Auto-Halt:
Tripwire Files:
Audit Trail:
No dependencies! Python 3.7+ stdlib only.
# Copy config example
cp config_example.json config.json
# Edit config with your protected paths
nano config.json
from canary import CanaryMonitor
# Initialize monitor
canary = CanaryMonitor('config.json')
# Check path before access
is_safe, reason = canary.check_path('/etc/passwd', 'read')
if not is_safe:
print(f"Blocked: {reason}")
exit(1)
# Check command before execution
is_safe, reason = canary.check_command('rm -rf /')
if not is_safe:
print(f"Blocked: {reason}")
exit(1)
# Get status
status = canary.get_status()
print(f"Violations: {status['violation_count']}/{status['halt_threshold']}")
# Check status
python3 canary.py status
# Check if path is safe
python3 canary.py check-path --path /etc/passwd --operation read
# Check if command is safe
python3 canary.py check-command --command "rm -rf /"
# Reset monitoring (clears violations)
python3 canary.py reset
Create honeypot files that should never be accessed:
# Create tripwire
python3 canary_tripwire.py create \
--path ~/.secrets/fake-api-key.txt \
--severity critical \
--description "Honeypot to detect credential snooping"
# List all tripwires
python3 canary_tripwire.py list
# Check for triggered tripwires
python3 canary_tripwire.py check
# View alert history
python3 canary_tripwire.py alerts --limit 10
# Remove tripwire
python3 canary_tripwire.py remove --path ~/.secrets/fake-api-key.txt
from canary_tripwire import TripwireManager
manager = TripwireManager()
# Create tripwire
manager.create_tripwire(
path='~/.aws/fake-credentials',
severity='critical',
description='Detects AWS credential access'
)
# Check all tripwires
triggered = manager.check_tripwires()
if triggered:
print(f"⚠️ {len(triggered)} tripwire(s) triggered!")
for alert in triggered:
print(f" - {alert['path']}: {alert['event']}")
Analyze logs and generate safety reports:
# Summary report
python3 canary_audit.py summary
# View violations by severity
python3 canary_audit.py violations --severity critical
# Timeline of recent events
python3 canary_audit.py timeline --hours 24
# Detect suspicious patterns
python3 canary_audit.py patterns
# Export full report
python3 canary_audit.py export --output report.json --format json
python3 canary_audit.py export --output report.md --format markdown
from canary_audit import CanaryAuditor
auditor = CanaryAuditor('canary.log')
# Generate summary
summary = auditor.generate_summary_report()
print(f"Total violations: {summary['total_violations']}")
# Get critical violations
critical = auditor.get_violations_by_severity('critical')
# Detect patterns
patterns = auditor.detect_patterns()
if patterns['rapid_violations']:
print("⚠️ Rapid violation sequence detected!")
# Export report
auditor.export_report('safety-report.md', format='markdown')
See config_example.json for all options.
{
"protected_paths": [
"/etc/",
"~/.ssh/",
"~/critical-data/"
],
"forbidden_patterns": [
"rm\\s+-rf\\s+/",
"chmod\\s+777",
"curl.*\\|\\s*sh"
],
"halt_threshold": 5,
"rate_limits": {
"file_operations": {"limit": 100, "window": 60},
"command_executions": {"limit": 20, "window": 60}
}
}
from canary import CanaryMonitor
canary = CanaryMonitor('config.json')
def safe_file_read(path):
"""Read file with Canary check."""
is_safe, reason = canary.check_path(path, 'read')
if not is_safe:
raise PermissionError(reason)
with open(path, 'r') as f:
return f.read()
def safe_command(cmd):
"""Execute command with Canary check."""
is_safe, reason = canary.check_command(cmd)
if not is_safe:
raise PermissionError(reason)
import subprocess
cmd_list = cmd.split() if isinstance(cmd, str) else cmd
return subprocess.run(cmd_list, capture_output=True)
# Before deploying agent, verify Canary setup
from canary import CanaryMonitor
canary = CanaryMonitor('config.json')
# Verify protected paths are configured
status = canary.get_status()
if status['protected_paths_count'] == 0:
print("⚠️ No protected paths configured!")
exit(1)
# Test tripwire detection
from canary_tripwire import TripwireManager
manager = TripwireManager()
# Create test tripwire
manager.create_tripwire('/tmp/canary-test.txt', severity='high')
# Verify it exists
triggered = manager.check_tripwires()
if not any(t['path'] == '/tmp/canary-test.txt' for t in triggered):
print("✅ Tripwire system operational")
# Cleanup
manager.remove_tripwire('/tmp/canary-test.txt', delete_file=True)
Deploy Canary alongside autonomous agents to prevent:
Each agent gets its own Canary instance with custom rules:
Use Canary during agent development:
Run Canary in production:
┌─────────────────┐
│ Your Agent │
└────────┬────────┘
│
▼
┌─────────────────┐ ┌──────────────────┐
│ CanaryMonitor │◄────►│ config.py │
│ (canary.py) │ │ (your rules) │
└────────┬────────┘ └──────────────────┘
│
├─────► canary.log (action log)
│
▼
┌─────────────────┐ ┌──────────────────┐
│ TripwireManager │◄────►│ .canary_tripwires│
│ (tripwire.py) │ │ (honeypot files) │
└────────┬────────┘ └──────────────────┘
│
└─────► alerts.log
┌─────────────────┐
│ CanaryAuditor │───► reports (JSON/MD)
│ (audit.py) │
└─────────────────┘
Begin with strict rules, relax as needed:
protected_paths = [
'/', # Protect entire filesystem initially
]
halt_threshold = 3 # Low threshold to catch issues early
Place tripwires in sensitive locations:
# Daily audit
python3 canary_audit.py summary
# Weekly deep dive
python3 canary_audit.py patterns
python3 canary_audit.py export --output weekly-report.md --format markdown
# Verify Canary blocks what it should
canary = CanaryMonitor('config.json')
# These should all be blocked
assert not canary.check_path('/etc/passwd', 'delete')[0]
assert not canary.check_command('rm -rf /')[0]
assert not canary.check_command('chmod 777 /tmp')[0]
print("✅ Canary configuration verified")
See LIMITATIONS.md for details.
Key constraints:
MIT License - See LICENSE
Author: Shadow Rose
AI agents can do a lot of damage quickly:
Canary provides defense-in-depth:
Simple, zero-dependency safety for autonomous agents.
Configuration is loaded from a JSON file. This is safe to share — no code execution.
.json file — CanaryMonitor raises ValueError if given a non-JSON path~ and relative paths are expanded via Path.expanduser().resolve() before creation and lookup. '~/.aws/fake-credentials' will be placed in your actual home directory, not a literal ~ path.create_tripwire will not overwrite existing files — it checks for pre-existing files and refuses to proceed. Use dedicated empty paths for tripwires.auditd for production deployments.This software is provided "AS IS", without warranty of any kind, express or implied.
USE AT YOUR OWN RISK.
By downloading, installing, or using this software, you acknowledge that you have read this disclaimer and agree to use the software entirely at your own risk.
| 🐛 Bug Reports | TheShadowyRose@proton.me |
| ☕ Ko-fi | ko-fi.com/theshadowrose |
| 🛒 Gumroad | shadowyrose.gumroad.com |
| @TheShadowyRose | |
| 🐙 GitHub | github.com/TheShadowRose |
| 🧠 PromptBase | promptbase.com/profile/shadowrose |
Built with OpenClaw — thank you for making this possible.
🛠️ Need something custom? Custom OpenClaw agents & skills starting at $500. If you can describe it, I can build it. → Hire me on Fiverr
📦 Install note: The slug
canarywas already taken on ClawHub. Install this skill using:clawhub install canary-sr