T06 · System Persistence
Error
- Location
- entry.js:75
- Finding
- Persistent Scheduled Task Installed Through the User Crontab<![CDATA[ ## Vulnerability Details **File Location**: `entry.js:75-100` **Vulnerability Type**: Persistent scheduled-task registration **Risk Level**: High ### Vulnerable Code ```js installCronJob() { console.log('⏰ 安装定时维护任务...'); const cronLine = '30 3 * * * ~/.openclaw/skills/system-maintenance/scripts/daily-maintenance-optimization.sh >> /tmp/openclaw-maintenance.log 2>&1'; try { // 获取当前 crontab let currentCron = ''; try { currentCron = execSync('crontab -l 2>/dev/null', { encoding: 'utf8' }); } catch { currentCron = ''; } // 检查是否已存在 if (currentCron.includes('daily-maintenance-optimization.sh')) { console.log('ℹ️ 定时任务已存在'); return; } // 添加新任务 const newCron = currentCron + '\n' + cronLine + '\n'; execSync(`echo "${newCron.trim()}" | crontab -`); console.log('✅ 定时任务安装完成 (每天 3:30)'); } catch (error) { console.error('❌ 定时任务安装失败:', error.message); } } ``` ### Technical Analysis The `install-cron` command modifies the invoking user's persistent crontab. The resulting task executes `daily-maintenance-optimization.sh` every day at 03:30 and survives termination of the Skill process, logout, and subsequent sessions. Scheduled automation is related to the declared maintenance functionality and is exposed as an explicit CLI command rather than silently installed. Nevertheless, persistent scheduler modification exceeds the privileges necessary for the Skill's on-demand cleanup and status-check operations. The implementation does not display the exact proposed change, obtain informed confirmation, validate the executable target, or provide a corresponding removal operation. The cron entry references a file that is absent from the audited artifact. If a file is subsequently created or replaced at that location, cron will execute it automatically with the installing user's privileges. ### Attack Path 1. A user invokes `node entry.js install-cron`. 2. The Skill reads t ...[truncated 934 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Keep scheduled automation disabled by default. - Before installation, display the exact cron entry and require explicit user confirmation. - Verify that the target script exists, is a regular file, is owned by the expected user, is not writable by untrusted users, and matches a trusted integrity hash. - Resolve and use an absolute script path rather than relying on `~` expansion. - Provide an idempotent `uninstall-cron` command that removes only entries managed by this Skill. - Mark managed entries with unique begin/end comments instead of identifying them by a broad substring. - Back up the existing crontab and restore it if installation fails. - Warn against installing the task from a privileged account unless privileged execution is strictly required. ]]>
