T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/setup-watchdog.sh:121
- Finding
- Overbroad Cron Filtering Can Delete Unrelated Scheduled Tasks<![CDATA[ ## Vulnerability Details **File Location**: `scripts/setup-watchdog.sh`, lines 121-125 **Vulnerability Type**: Unsafe modification of user cron configuration **Risk Level**: Medium ### Vulnerable Code ```bash # Remove existing watchdog cron if any (crontab -l 2>/dev/null | grep -v "watchdog.sh") | crontab - # Add new cron job (crontab -l 2>/dev/null; echo "$CRON_JOB") | crontab - ``` Related unsafe removal instructions also appear in: ```bash crontab -l | grep -v watchdog | crontab - ``` at `SKILL.md:44` and `scripts/setup-watchdog.sh:137`. ### Technical Analysis The installer removes every cron entry containing the generic substring `watchdog.sh`, rather than removing only the exact entry owned by this skill. The documented uninstall command is even broader and removes every line containing `watchdog`. Consequently, unrelated monitoring, backup, security, or maintenance tasks can be silently deleted. The read-filter-write approach also lacks synchronization: a concurrent cron update occurring between the two `crontab -l` operations can be lost. The watchdog's user-level cron registration is consistent with its declared self-healing function and does not itself exceed the required privilege boundary. The unsafe matching and modification strategy, however, affects cron entries outside the skill's ownership. ### Attack Path 1. The user already has an unrelated cron task whose command or path contains `watchdog.sh` or `watchdog`. 2. The user runs `scripts/setup-watchdog.sh`, or follows the documented removal command. 3. `grep -v` removes the unrelated entry along with the OpenClaw entry. 4. The modified cron table is installed without warning or backup. 5. The unrelated monitoring or maintenance task ceases to run, potentially concealing failures or causing service disruption. A local process that can race cron modifications could also arrange for legitimate concurrent changes to be overwritten. ### Impact Assessment The impact is limited t ...[truncated 252 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Install a uniquely marked cron entry, for example: ```cron # BEGIN OPENCLAW_GATEWAY_WATCHDOG * * * * * /home/user/.openclaw/watchdog.sh # END OPENCLAW_GATEWAY_WATCHDOG ``` - Remove only the exact command or the content between those unique markers. - Avoid generic filters such as `grep -v watchdog`. - Back up the current crontab before modification. - Generate the complete replacement in a secured temporary file and verify it before installation. - Prefer an idempotent installer that detects an exact existing entry and leaves all unrelated lines unchanged. - Provide a dedicated uninstall script using the same exact ownership markers. ]]>
