T06 · System Persistence
Error
- Location
- auto-evolve-daemon.sh:10
- Finding
- Indefinite Background Daemon Repeatedly Executes Self-Modifying Code<![CDATA[ ## Vulnerability Details **File Location**: `auto-evolve-daemon.sh:10-22` **Vulnerability Type**: Indefinite background execution and autonomous code modification **Risk Level**: High ### Vulnerable Code ```bash while true; do echo "" >> $LOG_FILE echo "[$(date)] Running self-evolution..." >> $LOG_FILE cd $SKILL_PATH python3 scripts/self_evolve.py >> $LOG_FILE 2>&1 echo "[$(date)] Evolution cycle complete. Sleeping 30 minutes..." >> $LOG_FILE # Run another evolution cycle every 30 minutes sleep 1800 done ``` The invoked evolution engine writes directly to executable code: ```python if content != original: with open(script_path, 'w', encoding='utf-8') as f: f.write(content) ``` It also rewrites the Skill definition: ```python with open(skill_md, 'w', encoding='utf-8') as f: f.write(content) ``` ### Technical Analysis The daemon runs indefinitely and invokes `scripts/self_evolve.py` every 30 minutes. That module can rewrite `scripts/process_record.py`, `SKILL.md`, generated support modules, changelogs, and evolution logs. Medical-record structuring does not require a perpetual background loop or autonomous modification of reviewed executable files. The implementation has no integrity verification, trusted update source, file locking, rollback mechanism, change approval, or limit on the number of cycles. The repository does not contain an automatic startup-service or cron installer, so cross-reboot persistence is not established by the reviewed code alone. Nevertheless, once manually launched or launched by an external supervisor, the script remains active indefinitely and continually mutates the installed Skill. ### Attack Path 1. A user, deployment script, or external process launches `auto-evolve-daemon.sh`. 2. The script enters an unbounded `while true` loop. 3. Every 30 minutes, it runs `scripts/self_evolve.py`. 4. The evolution engine rewrites executable and instruction files in ...[truncated 781 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove `auto-evolve-daemon.sh` from the distributed Skill. 2. Remove all runtime mutation of executable files and `SKILL.md`. 3. Distribute updates as reviewed, immutable, versioned releases. 4. Sign release artifacts and verify signatures or checksums before installation. 5. If maintenance tooling must remain: - Require explicit manual invocation. - Operate on a temporary copy. - Generate a reviewable patch rather than overwriting files. - Require user approval before applying changes. - Implement locking, rollback, and bounded execution. 6. Run the medical parser with write access limited to a dedicated data directory, not its own executable directory. ]]>
