T06 · System Persistence
- Location
- scripts/setup.sh:155
- Finding
- Unconditional Persistent Launch Agent Installation<![CDATA[ ## Vulnerability Details **File Location**: `scripts/setup.sh:155-214` **Vulnerability Type**: Unconditional cross-session service persistence **Risk Level**: High ### Vulnerable Code ```bash PLIST="$HOME/Library/LaunchAgents/${PLIST_LABEL}.plist" launchctl stop "$PLIST_LABEL" 2>/dev/null || true launchctl unload "$PLIST" 2>/dev/null || true cat > "$PLIST" << PLISTEOF <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>${PLIST_LABEL}</string> <key>ProgramArguments</key> <array> <string>$(which python3)</string> <string>${SCRIPTS_DIR}/server.py</string> </array> <key>WorkingDirectory</key> <string>${SKILL_DIR}</string> <key>RunAtLoad</key> <true/> <key>KeepAlive</key> <dict> <key>SuccessfulExit</key> <false/> </dict> <key>ThrottleInterval</key> <integer>5</integer> <key>StandardOutPath</key> <string>/tmp/videochat-withme.log</string> <key>StandardErrorPath</key> <string>/tmp/videochat-withme.log</string> <key>EnvironmentVariables</key> <dict> <key>AGENT_NAME</key> <string>${AGENT_NAME}</string> <key>USER_NAME</key> <string>${USER_NAME}</string> <key>PORT</key> <string>${PORT}</string> <key>PATH</key> <string>/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin</string> PLISTEOF if [ -n "$SSL_CERT" ] && [ -n "$SSL_KEY" ]; then cat >> "$PLIST" << SSLEOF <key>SSL_CERT</key> <string>${SSL_CERT}</string> <key>SSL_KEY</key> <string>${SSL_KEY}</string> SSLEOF fi cat >> "$PLIST" << ENDEOF </dict> </dict> </plist> ENDEOF launchctl load "$PLIST" ``` ### Technical Analysis The setup process always creates and loads a per-user launch agent. `RunAtLoad` causes the service to start whenever the user logs in, while ...[truncated 1628 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Do not install a launch agent during default or automatic setup. 2. Add an explicit option such as `--install-service` and require informed user confirmation before using it. 3. Run the server in the foreground or start it only for the duration of a call by default. 4. Add a complete uninstall operation using the appropriate `launchctl bootout` or unload command, followed by deletion of the plist. 5. Make `stop.sh` distinguish between temporary stopping and permanent service removal. 6. Clearly document startup, restart, and removal behavior before installation. 7. Consider configuring `RunAtLoad` and `KeepAlive` as disabled unless the user expressly requests continuous availability. ]]>
