T06 · System Persistence
- Location
- SKILL.md:33
- Finding
- Persistent Health Server Registered with Unnecessary Elevated Privileges<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 33-65 and 212-226 **Vulnerability Type**: Cross-session startup persistence and excessive privilege assignment **Risk Level**: High ### Vulnerable Code ```powershell $action = New-ScheduledTaskAction -Execute "pythonw.exe" -Argument "server.py" -WorkingDirectory "<health-sync-dir>" $trigger = New-ScheduledTaskTrigger -AtLogon Register-ScheduledTask -TaskName "HealthSyncServer" -Action $action -Trigger $trigger -RunLevel Highest -Force Start-ScheduledTask -TaskName "HealthSyncServer" ``` ```xml <key>ProgramArguments</key><array> <string>python3</string><string>server.py</string> </array> <key>WorkingDirectory</key><string>HEALTH_SYNC_DIR</string> <key>RunAtLoad</key><true/> <key>KeepAlive</key><true/> ``` ```bash launchctl load ~/Library/LaunchAgents/com.health-sync.server.plist ``` ### Technical Analysis The Skill instructs the Agent to register the generated server as a Windows scheduled task or macOS LaunchAgent. Both mechanisms survive the Skill execution and future Agent sessions. Continuous background operation is relevant to the declared real-time synchronization functionality. However, the Windows task uses `-RunLevel Highest`, even though a Flask server listening on an unprivileged port and writing to the user's project directory does not require administrative execution. This exceeds the minimum privileges necessary. The service runs `server.py` using relative executable and script references. If the script, working directory, or resolved Python executable is replaced or compromised, attacker-controlled code will execute automatically at subsequent logons. On Windows, it may execute with the task's elevated privileges. ### Attack Path 1. The user or Agent follows the setup instructions. 2. A scheduled task or LaunchAgent is installed and configured to run at logon and remain active. 3. An attacker gains write access to `server.py`, its working directory, or a dependency ...[truncated 647 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Make persistent startup an explicit, informed, opt-in choice rather than a mandatory setup step. - Remove `-RunLevel Highest`; register the Windows task with ordinary user privileges. - Use absolute paths for the Python interpreter and `server.py`. - Restrict write permissions on the server script, configuration, and dependency environment. - Prefer a dedicated, minimally privileged service account where persistent operation is required. - Add documented removal commands for both the scheduled task and LaunchAgent. - Configure restart limits instead of unconditional `KeepAlive` behavior. - Verify the script's ownership and integrity before each service start. ]]>
