T06 · System Persistence
Error
- Location
- SKILL.md:67
- Finding
- Recurring Cron Persistence Overwrites the Existing User Crontab<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:67-72` **Vulnerability Type**: Unsafe scheduled-task persistence **Risk Level**: High ### Vulnerable Code ```bash ### Set up daily cron ```bash echo "0 3 * * * bash $(pwd)/scripts/backup.sh /path/to/backup-config.json" | crontab - ``` ``` ### Technical Analysis The documented command installs a cron entry that executes the backup script every day at 03:00, creating cross-session persistence. Automated scheduling is relevant to the declared backup functionality, but this implementation is not least-impact: - `crontab -` replaces the user's entire existing crontab instead of adding only the backup entry. - No confirmation, backup, duplicate detection, or rollback mechanism is provided. - The script path produced by `$(pwd)` is inserted into the cron command without robust shell quoting. - The persistent task repeatedly accesses highly sensitive personality files, memory, configuration, projects, scripts, and potentially the complete secrets directory. - If the Skill directory or referenced configuration becomes writable by another party, the scheduled task becomes a recurring execution or data-exfiltration channel under the affected user's account. The persistence is disclosed rather than hidden, but it still exceeds the minimum safe implementation needed for optional backup scheduling because it can destroy unrelated scheduled tasks and does not protect the integrity of the files executed by cron. ### Attack Path 1. A user follows the documented cron setup command. 2. The piped input replaces the user's complete crontab with the single backup entry. 3. Any unrelated cron jobs previously configured for that user are removed. 4. Cron subsequently invokes `scripts/backup.sh` every day under the user's account. 5. If an attacker can later modify the Skill directory, backup configuration, or referenced script, the attacker-controlled content is executed automatically on the next scheduled run. ...[truncated 578 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Make automated scheduling explicitly optional and require informed user confirmation. - Preserve existing jobs instead of replacing the complete crontab. - Add a uniquely marked, idempotent entry only if it does not already exist. - Back up the current crontab before changing it and document a precise uninstall procedure. - Resolve paths before installation and safely quote or reject paths containing newlines or other unsafe characters. - Verify that the scheduled script and configuration are owned by the intended user and are not writable by group members or other users. - Prefer a dedicated user-level scheduler unit with explicit permissions, logging, and lifecycle controls. - Document that the scheduled process repeatedly reads sensitive data and identify the exact delivery destination. A safer installation flow should preserve existing entries, for example by collecting `crontab -l` output, checking for a unique marker, and appending one validated entry rather than piping a replacement crontab directly. ]]>
