T06 · System Persistence
- Location
scripts/watch-events-smart.js:83- Finding
Unbounded User-Level Cron Persistence Through Event Watch Scheduling
- Content
View full analysis
`'${String(value).replace(/'/g, `'"'"'`)}'`; const shellScript = `#!/bin/bash cd "$(dirname "$0")" exec node ${shellQuote(scriptPath)} ${shellQuote(`@${configPath}`)} `; const shellPath = join(cronDir, `${jobName}.sh`); writeFileSync(shellPath, shellScript, { mode: 0o755 }); const cronEntry = `* * * * * ${shellPath} >> ${join(cronDir, `${jobName}.log`)} 2>&1`; let currentCrontab = ''; try { currentCrontab = execSync('crontab -l 2>/dev/null || echo ""').toString(); } catch (e) { currentCrontab = ''; } const lines = currentCrontab.split('\n').filter(line => !line.includes(shellPath)); lines.push(cronEntry); const newCrontab = lines.join('\n') + '\n'; const tmpCrontab = join(tmpdir(), `crontab-${process.pid}.tmp`); writeFileSync(tmpCrontab, newCrontab); execFileSync('crontab', [tmpCrontab]); } ``` ```js if (config.schedule?.enabled) { const result = createCronJob(config); if (result.success) { cons ...[truncated 2517 chars]- Remediation
View remediation
