T06 · System Persistence
Error
- Location
- lifecycle.js:304
- Finding
- Automatic Installation of Persistent Watchdogs<![CDATA[ ## Vulnerability Details **File Location**: `lifecycle.js:304-325`, with daemon startup at `lifecycle.js:93-103` and `lifecycle.js:797-800` **Vulnerability Type**: Persistent scheduled task and detached watchdog installation **Risk Level**: High ### Complete Code Snippet ```javascript if (!exists) { console.log('[Lifecycle] Creating missing cron job: evolver_watchdog_robust...'); // Optimization: Reduced frequency from 10m to 30m to reduce exec noise const cmdStr = `${openclawCli} cron add --name "evolver_watchdog_robust" --every "30m" --session "isolated" --message "exec: node skills/feishu-evolver-wrapper/lifecycle.js ensure" --no-deliver`; execSync(cmdStr); console.log('[Lifecycle] Watchdog cron job created successfully.'); } else { // If disabled, enable it if (exists.enabled === false) { console.log(`[Lifecycle] Enabling disabled watchdog job (ID: ${exists.id})...`); execSync(`${openclawCli} cron edit "${exists.id}" --enable`); } // Optimization: Enforce 30m interval if currently 10m (reduce exec usage) if (exists.schedule && exists.schedule.everyMs === 600000) { console.log(`[Lifecycle] Optimizing watchdog frequency to 30m (ID: ${exists.id})...`); execSync(`${openclawCli} cron edit "${exists.id}" --every "30m"`); } } ``` The corresponding `ensure` operation also starts a detached internal daemon: ```javascript const child = spawn(process.execPath, [__filename, 'daemon-loop'], { detached: true, stdio: ['ignore', out, err], cwd: __dirname }); fs.writeFileSync(DAEMON_PID_FILE, String(child.pid)); child.unref(); ``` ### Technical Analysis Starting or ensuring the wrapper creates or re-enables an OpenClaw cron job that periodically invokes `lifecycle.js ensure`. The `ensure` action can additionally launch a detached daemon that monitors and restarts the evolution loop. A watchdog is related to the declared lifecycle-management functionality, and `SKILL.md` mentions it. However, the impleme ...[truncated 1573 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Make watchdog installation a separate explicit command, such as `lifecycle.js install-watchdog`. - Require affirmative user consent before creating or enabling scheduled jobs. - Do not start the detached daemon from the ordinary `ensure` action unless persistence was explicitly enabled. - Add an `uninstall-watchdog` command that removes the cron job, stops the daemon, and deletes associated state and PID files. - Make `stop` either disable all restart mechanisms or clearly distinguish `stop-loop` from `disable-watchdog`. - Record persistence state locally and display it prominently in `status`. - Avoid running both a scheduled watchdog and a detached watchdog unless the user explicitly requests redundant monitoring. - Update `SKILL.md` to match the implemented 30-minute interval and document installation, removal, and restart behavior. ]]>
