T06 · System Persistence
Error
- Location
- scripts/install.sh:70
- Finding
- Persistent system service and scheduled task run with excessive privileges<![CDATA[ ## Vulnerability Details **File Location**: `scripts/install.sh:70-99` **Vulnerability Type**: System-level persistence and excessive privileges **Risk Level**: High ### Vulnerable Code ```bash CRON_MARKER="# agent-guardian" crontab -l 2>/dev/null | grep -v "$CRON_MARKER" > /tmp/crontab-guardian.tmp || true echo "*/$REPORT_INTERVAL * * * * $SCRIPT_DIR/smart-status-report.sh >> /tmp/status-report.log 2>&1 $CRON_MARKER" >> /tmp/crontab-guardian.tmp crontab /tmp/crontab-guardian.tmp rm -f /tmp/crontab-guardian.tmp if command -v systemctl &>/dev/null && command -v inotifywait &>/dev/null; then cat > /etc/systemd/system/agent-guardian-query.service << EOF [Unit] Description=Agent Guardian Status Query Daemon After=network.target [Service] Type=simple ExecStart=$SCRIPT_DIR/status-query-daemon.sh Restart=always RestartSec=5 User=root [Install] WantedBy=multi-user.target EOF systemctl daemon-reload systemctl enable agent-guardian-query.service 2>/dev/null systemctl restart agent-guardian-query.service fi ``` ### Technical Analysis The installer creates two cross-session persistence mechanisms: 1. A recurring crontab entry that invokes `smart-status-report.sh`. 2. A boot-enabled systemd service configured with `Restart=always`. Scheduling and background monitoring are consistent with the Skill's declared status-reporting functionality. However, running the query daemon explicitly as `root` and installing it as a system-wide service exceed the minimum privileges needed to read Skill-owned state and invoke the OpenClaw command-line client. The service executes its script directly from the Skill installation directory. If that directory or script can later be modified by a less-privileged account, the systemd service turns such write access into persistent root code execution. The installer also provides no corresponding uninstall or rollback procedure. ### Attack Path 1. The installer is executed with sufficient privileges to write und ...[truncated 840 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Run the daemon under a dedicated unprivileged account rather than `User=root`. - Prefer a user-level systemd service and timer under `~/.config/systemd/user`. - Apply systemd hardening such as: - `NoNewPrivileges=true` - `PrivateTmp=true` - `ProtectSystem=strict` - `ProtectHome=true` - `RestrictAddressFamilies=` - Explicit `ReadWritePaths` for the minimum required state directory - Install scripts into a root-owned, non-writable directory if a privileged service is unavoidable. - Require explicit, separate confirmation before creating either persistence mechanism. - Provide an uninstall script that disables and removes the service, reloads systemd, removes the cron entry, and deletes runtime state. - Prefer an OpenClaw-native scheduler or event-driven callback when that can provide the functionality without system-wide persistence. ]]>
