T06 · System Persistence
Error
- Location
- SKILL.md:60
- Finding
- Recurring Privileged Cron Execution Creates a Persistence and Privilege-Escalation Risk<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:60-65` **Vulnerability Type**: `T06: System Persistence` **Risk Level**: High ### Vulnerable Code ```bash ## Example crontab entry # Read every 30 minutes */30 * * * * sudo python3 ~/scripts/dht/main.py >> /var/log/dht.log 2>&1 ``` ### Technical Analysis The documentation recommends configuring a cron entry that executes the sensor script every 30 minutes through `sudo`. This creates cross-session scheduled execution and exceeds the minimum privileges required for an on-demand temperature and humidity reading. The command executes a script located below a user's home directory. If the script or a parent directory is writable by a less-privileged user, replacing the script can turn the scheduled command into a privileged execution mechanism. Successful unattended execution depends on the host's `sudoers` configuration; if passwordless execution is not permitted, the task may fail instead. If passwordless execution is permitted, compromise of the referenced script can result in root-level command execution. The command also references `scripts/dht/main.py`, while the package contains `scripts/main.py`. This mismatch may lead users to create wrappers or copies at an unintended, insufficiently protected location. ### Attack Path 1. A user follows the documentation and installs the recurring cron entry. 2. The system permits unattended `sudo` execution for Python or the referenced command. 3. An attacker compromises the account, another process running as that account, or any writable component of the referenced path. 4. The attacker replaces `~/scripts/dht/main.py` with malicious Python code. 5. Cron reaches the next 30-minute interval and invokes the modified script through `sudo`. 6. The attacker's code executes with the privileges granted by the applicable `sudoers` rule, potentially including root. ### Impact Assessment If unattended `sudo` is available, exploitation may provide persisten ...[truncated 489 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Remove the cron example unless continuous monitoring is an explicit part of the Skill's declared functionality. - Make any scheduling procedure clearly optional and explain its persistence and security implications. - Do not invoke the sensor reader through unrestricted `sudo`. Grant only the minimum GPIO device access required, such as through a dedicated group or narrowly scoped device permissions. - Run scheduled monitoring under a dedicated, unprivileged service account. - Reference an absolute path to a root-owned, non-user-writable script rather than a path beneath a user's home directory. - If elevated execution is unavoidable, use a narrowly scoped `sudoers` rule for a fixed root-owned executable; do not grant general Python execution. - Protect log files with restrictive ownership and permissions, and configure rotation. - Add execution time limits and overlap prevention to ensure a failed sensor read cannot accumulate scheduled processes. - Correct the documented path to match the packaged script location. ]]>
