T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/disk-cleanup.sh:359- Finding
Default cleanup performs privileged host-wide log destruction and persistent journald reconfiguration
- Content
View full analysis
Vulnerability Details
File Location:
scripts/disk-cleanup.sh, lines 359-393 and 525-552
Vulnerability Type: Host-wide destructive operations without explicit privileged-operation opt-in
Risk Level: HighVulnerable Code
bash # Also set persistent limit to prevent regrowth JOURNAL_CONF="/etc/systemd/journald.conf.d/openclaw-limit.conf" if [[ ! -f "$JOURNAL_CONF" && "$DRY_RUN" == "false" ]]; then mkdir -p /etc/systemd/journald.conf.d cat > "$JOURNAL_CONF" <<'JEOF' # Installed by openclaw-disk-cleanup.sh # Prevents journal from growing beyond 500M [Journal] SystemMaxUse=500M SystemKeepFree=1G MaxFileSec=1week JEOF systemctl restart systemd-journald 2>/dev/null || true log " Installed journal size limit (500M max)" ACTIONS+=("Installed journald 500M limit") fibash # Rotated syslogs older than current + 1 for rotlog in /var/log/syslog.[2-9]* /var/log/auth.log.[2-9]*; do if [[ -f "$rotlog" ]]; then RSIZE=$(stat -c%s "$rotlog" 2>/dev/null || echo 0) SYSLOG_FREED=$((SYSLOG_FREED + RSIZE)) if [[ "$DRY_RUN" == "false" ]]; then rm -f "$rotlog" fi fi done # btmp: SSH brute-force attempts log. Can grow huge on public VPS. # Truncate instead of delete (system expects it to exist). BTMP="/var/log/btmp" if [[ -f "$BTMP" ]]; then BTMP_SIZE=$(stat -c%s "$BTMP" 2>/dev/null || echo 0) if [[ $BTMP_SIZE -gt 10485760 ]]; then # >10MB SYSLOG_FREED=$((SYSLOG_FREED + BTMP_SIZE)) if [[ "$DRY_RUN" == "false" ]]; then : > "$BTMP" log " Truncated btmp ($(bytes_to_human "$BTMP_SIZE"))" else log " [DRY-RUN] Would truncate btmp ($(bytes_to_human "$BTMP_SIZE"))" fi fi fiTechnical Analysis
A normal live run can write a persistent system configuration under
/etc, restartsystemd-journald, remove rotated authentication and system logs, and ...[truncated 2265 chars]- Remediation
View remediation
Remediation Suggestions
- Move all
/etc,systemctl,/var/log, and host-journal operations behind an explicit--systemor--host-cleanupoption. Keep this option disabled by default. - Require an explicit confirmation before deleting security logs or changing persistent service configuration. In unattended operation, require a separate configuration value that identifies the approved retention policy.
- Check
EUIDbefore host-level operations and fail with a clear message rather than relying on individual commands to fail. - Do not truncate
btmpor delete authentication logs by default. Use the host's configured log-rotation mechanism and retain records according to organizational security and compliance policies. - Prefer temporary journal vacuuming over installing a persistent journald configuration. If persistent configuration is requested, back up existing settings and report the exact system-wide impact.
- Restrict system-log cleanup to explicitly enumerated files and approved retention ages. Record every deletion in a separate protected audit log.
- Update
SKILL.mdto clearly distinguish application cleanup from optional privileged host maintenance and document that host-level operations affect unrelated services.
- Move all
