fix(security): harden installation with scoped sudo, fail2ban, and auto-updates#11
Merged
alauppe merged 2 commits intoopenclaw:mainfrom Feb 6, 2026
Merged
Conversation
…to-updates Security improvements: 1. CRITICAL: Scope sudo access for clawdbot user - Changed from 'ALL=(ALL) NOPASSWD: ALL' to specific commands only - Now limited to: systemctl for clawdbot service, tailscale, journalctl - Prevents full root compromise if application is exploited 2. CRITICAL: Fix hardcoded UID in systemd template - Changed XDG_RUNTIME_DIR from /run/user/1000 to dynamic - Uses clawdbot_uid_value variable with fallback 3. Add fail2ban for SSH brute-force protection - 5 failed attempts = 1 hour ban - Protects against automated attacks on exposed SSH 4. Add unattended-upgrades for automatic security updates - Security-only updates enabled by default - Automatic reboots disabled (manual control) 5. Update documentation - security.md: Document all 8 security layers - README.md: Add security features to list - AGENTS.md: Document security rationale and known limitations Known limitations documented: - macOS support incomplete (no launchd/pf) - IPv6 disabled in Docker - curl|bash pattern inherent risks Signed-off-by: Andrew Lauppe <andy@t5tele.com>
- Add documentation to sudoers explaining security rationale - Include instructions for operators to expand permissions if needed - Scope tailscale to: status, up, down, ip, version, ping, whois - Add note about up/down allowing flags like --advertise-exit-node - Document daemon-reload affecting all units - Remove redundant fail2ban config (logpath, duplicate maxretry/bantime) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses critical security concerns in the recommended installation method.
Critical Fixes
1. Scoped Sudo Access (was: full NOPASSWD root)
Before:
After:
Why: If the Clawdbot application were compromised, the attacker previously had full root access. Now they can only manage the clawdbot service.
2. Dynamic UID in Systemd Template (was: hardcoded 1000)
Before:
After:
Environment="XDG_RUNTIME_DIR=/run/user/{{ clawdbot_uid_value | default('1000') }}"Why: UID 1000 is not guaranteed. If clawdbot user gets a different UID, the service would fail.
New Security Features
3. Fail2ban for SSH Protection
4. Unattended-Upgrades for Automatic Security Updates
Documentation Updates
Known Limitations (Documented)
These are noted in documentation but not fixed in this PR:
Testing
Files Changed
roles/clawdbot/tasks/user.yml- Scoped sudo permissionsroles/clawdbot/tasks/firewall-linux.yml- Added fail2ban + unattended-upgradesroles/clawdbot/handlers/main.yml- Added fail2ban restart handlerroles/clawdbot/templates/clawdbot-host.service.j2- Dynamic UID, updated descriptiondocs/security.md- Comprehensive security documentationREADME.md- Updated features and security noteAGENTS.md- Security rationale and limitations