T06 · System Persistence
- Location
- BUDGET_README.md:133
- Finding
- Privileged System-Wide Service Persistence Instructions<![CDATA[ ## Vulnerability Details **File Location**: `BUDGET_README.md:133-139` **Vulnerability Type**: Privileged systemd service installation **Risk Level**: High ### Vulnerable Code ```bash ## Systemd Service # Install service sudo cp budget-collector.service /etc/systemd/system/ sudo systemctl daemon-reload sudo systemctl enable budget-collector sudo systemctl start budget-collector ``` ### Technical Analysis The installation instructions direct users to copy a service definition into the system-wide systemd directory and enable it using elevated privileges. This creates cross-session persistence and exceeds the minimum privilege required for a per-user monitoring dashboard. The instructions also conflict with the security statement in `SKILL.md`, which describes the service as a `--user` unit that runs without root privileges. Moreover, `budget-collector.service` is not present in the audited artifact. Consequently, users cannot inspect the intended unit from this package, and a same-named file from the working directory could be copied instead. Installing a service under `/etc/systemd/system/` allows its unit definition to specify arbitrary commands and potentially run them as root unless the unit explicitly drops privileges. ### Attack Path 1. An attacker places or substitutes a malicious file named `budget-collector.service` in the directory from which the documented commands are run. 2. The user follows the documentation and executes: `sudo cp budget-collector.service /etc/systemd/system/`. 3. The user reloads systemd and enables the service. 4. The attacker-controlled `ExecStart` command runs at service start and on subsequent boots. 5. If the unit does not contain an effective privilege restriction, the payload executes as root. ### Impact Assessment A successfully substituted unit could obtain persistent system-level code execution. Potential impact includes: - Arbitrary command execution as root, depending on the unit definition - Cr ...[truncated 318 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove all `sudo` and system-wide service installation instructions. 2. Include the actual service unit in the distributed artifact so it can be audited. 3. Install the unit under the current user's systemd configuration: ```bash mkdir -p ~/.config/systemd/user cp budget-collector.service ~/.config/systemd/user/ systemctl --user daemon-reload systemctl --user enable --now budget-collector ``` 4. Ensure the unit uses an absolute, trusted `ExecStart` path and includes appropriate hardening, such as: - `NoNewPrivileges=yes` - `PrivateTmp=yes` - `ProtectSystem=strict` - `ProtectHome=read-only`, with explicit writable paths - `RestrictSUIDSGID=yes` 5. Document how to disable and remove the unit. 6. Keep `SKILL.md` and `BUDGET_README.md` consistent regarding the service's privilege level. ]]>
