T06 · System Persistence
Error
- Location
- install.sh:48
- Finding
- Persistent LaunchAgent and Cron Registration Executes Mutable Workspace Scripts<![CDATA[ ## Vulnerability Details **File Location**: `install.sh:48-67`; `scripts/setup-heartbeat.sh:13-40`; `docs/shrimp-heartbeat-config.md:39-114` **Vulnerability Type**: Persistent scheduled execution from a mutable user workspace **Risk Level**: High ### Complete Code Snippet From `install.sh`: ```bash LAUNCH_AGENTS_DIR="$HOME/Library/LaunchAgents" # Copy configuration files cp "scripts/com.openclaw.heartbeat.plist" "$LAUNCH_AGENTS_DIR/" cp "scripts/com.openclaw.fswatch.plist" "$LAUNCH_AGENTS_DIR/" # Unload existing configurations if launchctl list | grep -q "com.openclaw.heartbeat"; then launchctl unload "$LAUNCH_AGENTS_DIR/com.openclaw.heartbeat.plist" 2>/dev/null || true fi if launchctl list | grep -q "com.openclaw.fswatch"; then launchctl unload "$LAUNCH_AGENTS_DIR/com.openclaw.fswatch.plist" 2>/dev/null || true fi # Load new configurations launchctl load "$LAUNCH_AGENTS_DIR/com.openclaw.heartbeat.plist" launchctl load "$LAUNCH_AGENTS_DIR/com.openclaw.fswatch.plist" ``` From `docs/shrimp-heartbeat-config.md`: ```xml <key>ProgramArguments</key> <array> <string>/Users/zhangyang/.openclaw/workspace/scripts/heartbeat-check.sh</string> </array> <key>StartCalendarInterval</key> <array> <dict><key>Hour</key><integer>8</integer><key>Minute</key><integer>0</integer></dict> <dict><key>Hour</key><integer>9</integer><key>Minute</key><integer>0</integer></dict> <dict><key>Hour</key><integer>10</integer><key>Minute</key><integer>0</integer></dict> <dict><key>Hour</key><integer>11</integer><key>Minute</key><integer>0</integer></dict> <dict><key>Hour</key><integer>12</integer><key>Minute</key><integer>0</integer></dict> <dict><key>Hour</key><integer>13</integer><key>Minute</key><integer>0</integer></dict> <dict><key>Hour</key><integer>14</integer><key>Minute</key><integer>0</integer></dict> <dict><key>Hour</key><integer>15</integer><key>Minute</key><integer>0</integer></dict> <dict><key>Hour</key><integer>16</in ...[truncated 2519 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Make persistent service installation an explicit opt-in step and display the full service definition before registration. 2. Prefer OpenClaw's built-in scheduling mechanism when available. 3. Install scripts into an immutable, package-owned directory rather than a general mutable workspace. 4. Verify script ownership, restrictive permissions, and a recorded cryptographic hash before service loading. 5. Generate portable paths from the authenticated user's home directory instead of using `/Users/zhangyang`. 6. Include the actual plist files in the reviewed package and validate them with `plutil`. 7. Provide an uninstall script that unloads and deletes both LaunchAgents, removes cron entries, and optionally removes generated logs. 8. Prevent simultaneous cron and LaunchAgent registration. 9. Use modern `launchctl bootstrap` and `bootout` operations with a per-user GUI domain where supported. ]]>
