T06 · System Persistence
- Location
install.sh:103- Finding
Automatic Installation of a Persistent System Service
- Content
View full analysis
/dev/null; then SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd)" cat > /tmp/layered-memory.service << EOF [Unit] Description=layered-memory-sys API Service After=network.target [Service] Type=simple WorkingDirectory=${SCRIPTS_DIR} ExecStart=$(which node) ${SCRIPTS_DIR}/scripts/start-api.mjs Restart=always RestartSec=5 Environment=NODE_ENV=production [Install] WantedBy=multi-user.target EOF if [ "$EUID" -eq 0 ]; then cp /tmp/layered-memory.service /etc/systemd/system/ systemctl daemon-reload systemctl enable layered-memory systemctl start layered-memory ``` ### Technical Analysis When native installation runs as root, the installer automatically copies a systemd unit into `/etc/systemd/system`, enables it at boot, starts it immediately, and configures it with `Restart=always`. A persistent service can be reasonable for an explicitly selected server deployment, but automatic system-level registration exceeds the minimum privilege needed merely to install or test the memory Skill. The installation flow does not request separate confirmation for persistence or create a dedicated restricted service account. The service therefore runs under the account used by systemd, which defaults to root because no `User=` directive is present. The service executes source code directly from the project directory. If an untrusted user can later modify that directory, the modified code will execute with the service's privileges after a restart or reboot. ### Attack Path 1. A user invokes `bash install.sh` as root and selects native installation. 2. The script writes the service definition through the predictable path `/tmp/layered-memory.service`. 3. The unit is copied to `/etc/systemd/system/layered-memory.service`. 4. `s ...[truncated 680 chars]- Remediation
View remediation
