T06 · System Persistence
Error
- Location
- SKILL.md:61
- Finding
- Persistent background service configured to survive user logout## Vulnerability Details **File Location**: `SKILL.md`, lines 61-88 **Vulnerability Type**: Cross-session service persistence **Risk Level**: High ### Vulnerable Code ```ini # ~/.config/systemd/user/bot-status.service [Unit] Description=Bot Status API After=network.target [Service] Type=simple WorkingDirectory=/path/to/bot-status ExecStart=/usr/bin/node server.js Restart=always RestartSec=5 Environment=PORT=3200 Environment=HOME=/home/youruser Environment=PATH=/usr/local/bin:/usr/bin:/bin [Install] WantedBy=default.target ``` ```bash systemctl --user daemon-reload systemctl --user enable --now bot-status loginctl enable-linger $USER # survive logout ``` ### Technical Analysis The setup instructs users to install and enable a systemd user service with `Restart=always`. It also enables user lingering through `loginctl enable-linger`, explicitly allowing the service to continue running after the user logs out. A persistent service may be appropriate for an intentionally deployed monitoring server, but this configuration exceeds the privileges required merely to run or evaluate the Skill. It creates a long-lived execution mechanism without presenting persistence as a separate, security-sensitive opt-in. The service will repeatedly execute `server.js` from a writable deployment directory. If that file or directory is subsequently compromised, attacker-controlled code can execute persistently under the affected user's account. The package does not include the referenced `server.js`, collectors, or package manifest, so the behavior of the program installed through this persistent mechanism cannot be independently verified from the audited artifact. ### Attack Path 1. A user follows the documented installation procedure. 2. The user service is enabled and immediately started with `systemctl --user enable --now`. 3. User lingering is enabled, allowing the service to run without an active logi ...[truncated 1055 chars]
- Remediation
- ## Remediation Suggestions 1. Make foreground execution the default and document persistence as a separate, explicit opt-in. 2. Do not enable user lingering by default. Require administrators to assess whether operation after logout is genuinely necessary. 3. Replace `Restart=always` with a more restrictive policy such as `Restart=on-failure`, with rate limits configured through `StartLimitIntervalSec` and `StartLimitBurst`. 4. Protect the service directory and executable files from unauthorized modification. The service account should own only the files it needs and should not use a broadly writable working directory. 5. Run the service under a dedicated, minimally privileged account with no interactive login and narrowly scoped access to OpenClaw data. 6. Add systemd hardening directives where compatible, including `NoNewPrivileges=true`, `PrivateTmp=true`, `ProtectSystem=strict`, `ProtectHome=true`, and narrowly scoped `ReadOnlyPaths` or `ReadWritePaths`. 7. Provide complete removal instructions covering service shutdown, disabling the unit, removal of the unit file, daemon reload, and disabling lingering when it is no longer required. 8. Include the referenced implementation files in the audited package so the executable installed through the persistence mechanism can be reviewed.
