T06 · System Persistence
- Location
scripts/dreaming-guard-pro.sh:1- Finding
Persistent Cron Execution Encourages Excessive Root Privileges
- Content
View full analysis
Vulnerability Details
File Location:
README.md:57-60,README.md:146-151,scripts/dreaming-guard-pro.sh:1-15
Vulnerability Type: Scheduled-task persistence and excessive privilege guidance
Risk Level: HighVulnerable Code
README.md:57-60:bash ### Cron Setup # Add to crontab (run every minute) * * * * * /path/to/dreaming-guard-pro/scripts/dreaming-guard-pro.sh >> /tmp/dreaming-guard.log 2>&1README.md:146-151:bash # Disable old script crontab -l | grep -v dreaming-guard.sh | crontab - # Enable new guard * * * * * /path/to/dreaming-guard-pro/scripts/dreaming-guard-pro.shscripts/dreaming-guard-pro.sh:1-15:bash #!/bin/bash # Dreaming Guard Pro - Cron Runner # Run one guard loop every minute # Installation: add * * * * * /path/to/dreaming-guard-pro.sh >> /tmp/dreaming-guard-pro.log 2>&1 with crontab -e set -e # Project path PROJECT_DIR="/root/.openclaw/workspace/projects/dreaming-guard-pro" NODE_PATH="$(which node)" # Enter project directory cd "$PROJECT_DIR" # Execute one loopTechnical Analysis
The documentation directs users to create a cron entry that executes the Skill every minute and survives individual Skill or agent sessions. Persistent monitoring can be consistent with the declared functionality, but cron is not the minimum mechanism necessary for one-time health checks or user-triggered operation.
The supplied runner hard-codes a project directory under
/root, encouraging installation or operation as the root user. Monitoring and maintaining a single user's OpenClaw workspace normally requires only that user's permissions. Running the Skill as root expands the effect of every filesystem flaw and any future modification of the project source.The migration command also reconstructs the complete crontab using a broad substring filter:
bash crontab -l | grep -v dreaming-guard.sh | ...[truncated 2096 chars]- Remediation
View remediation
Remediation Suggestions
- Make persistent operation explicitly optional and keep one-time, user-triggered health checks as the default.
- Run the guard under a dedicated unprivileged account with access limited to the required OpenClaw dreaming, archive, state, and log directories.
- Remove the hard-coded
/rootpath. Resolve the installation directory relative to the script or require a validated absolute path in a protected configuration file. - Provide an installer that creates one uniquely marked cron entry only after explicit confirmation, and provide a matching uninstaller.
- Never rebuild the entire crontab with a broad substring filter. Match an exact marker or use a dedicated crontab file after creating a backup.
- Verify that the project directory and loaded files are owned by the service account or root and are not writable by less-privileged users.
- Use a lock such as
flockto prevent overlapping executions. - Write logs to a permission-restricted application log directory rather than a predictable shared
/tmppath. - Document the exact persistence scope, required privileges, generated files, and removal procedure.
