T06 · System Persistence
- Location
- scripts/wb_mouse_checkin.py:769
- Finding
- Automatic Registration of a Cross-Session Windows Scheduled Task<![CDATA[ ## Vulnerability Details **File Location**: `scripts/wb_mouse_checkin.py:769-795` **Vulnerability Type**: Operating-system scheduled-task persistence **Risk Level**: High ### Code Evidence ```python def schedule_resume_task(): """Register a Windows scheduled task that runs this script in resume mode.""" try: py = sys.executable script = os.path.abspath(__file__) st = time.strftime("%H:%M", time.localtime(time.time() + RESUME_DELAY_SEC)) r = subprocess.run( ["schtasks", "/create", "/tn", RESUME_TASK_NAME, "/tr", f'"{py}" "{script}" -resume', "/sc", "once", "/st", st, "/f"], capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=30) if r.returncode == 0: print(f"Scheduled resume task [{RESUME_TASK_NAME}] for {st}") return True print(f"Failed to register scheduled task: {r.stderr.strip() or r.stdout.strip()}") return False except Exception as e: print(f"Scheduled-task registration error: {e}") return False def cancel_resume_task(): """Delete the resume scheduled task when it is no longer required.""" try: subprocess.run(["schtasks", "/delete", "/tn", RESUME_TASK_NAME, "/f"], capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=30) print(f"Deleted scheduled task [{RESUME_TASK_NAME}]") except Exception: pass ``` The task is activated from the update-recovery path at `scripts/wb_mouse_checkin.py:948-960`: ```python if btn: sx, sy, size = btn announce_move((sx, sy), "restart and upgrade") click_at(sx, sy, "restart and upgrade") mark_pending("update_restart") # Register an independent Windows task before WorkBuddy restarts. schedule_resume_task() ``` The same behavior is explicitly described in `SKILL.md:119-121`. ### Technical Analysis The GUI ch ...[truncated 2890 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove automatic scheduled-task creation from the normal `-run` workflow. 2. Report update/restart status to the user and require an explicit retry after WorkBuddy returns. 3. If resume scheduling is essential, expose it as a separate opt-in command and obtain informed confirmation before creating the task. 4. Generate a unique per-installation task name and reject existing-name collisions instead of using `/f`. 5. Configure an explicit expiration and deletion policy for the task. 6. Delete the task on every terminal path, including timeout, exception, failed check-in, and missing-window paths. 7. Check and report the actual return code from `schtasks /delete`. 8. Store the scheduled executable in a protected, immutable installation directory and verify its integrity before resumed execution. 9. Prefer `wb_api_checkin.py`, which performs the declared check-in without desktop persistence. ]]>
