T05 · Unauthorized Access and Privilege Escalation
- Location
- SKILL.md:46
- Finding
- Persistent Gateway Service Runs a PATH-Resolved Executable as Root## Vulnerability Details **File Location**: `SKILL.md`, lines 46-65 **Vulnerability Type**: Privilege escalation through unsafe executable resolution in a privileged persistent service **Risk Level**: High ### Vulnerable Code ```bash cat > /etc/systemd/system/openclaw-gateway.service << 'EOF' [Unit] Description=OpenClaw Gateway After=network-online.target Wants=network-online.target [Service] Type=simple ExecStart=/usr/bin/env openclaw gateway Restart=always RestartSec=5 User=root WorkingDirectory=/root/.openclaw Environment=HOME=/root [Install] WantedBy=multi-user.target EOF systemctl daemon-reload && systemctl enable openclaw-gateway ``` ### Technical Analysis The Skill creates a systemd service that executes the OpenClaw gateway with unrestricted root privileges and enables that service across reboots. The declared gateway functionality does not demonstrate a requirement for root access. The command `ExecStart=/usr/bin/env openclaw gateway` does not pin `openclaw` to an absolute, administrator-validated executable path. Instead, `/usr/bin/env` searches the service's effective `PATH`. If a lower-privileged user or compromised installation process can replace a selected `openclaw` executable or place an attacker-controlled executable earlier in a writable search location, systemd will execute that file as root. `Restart=always` causes the process to be executed repeatedly following failures, while enabling the service makes the unsafe configuration survive reboots. These settings increase the persistence and reliability of exploitation. The service also lacks common systemd sandboxing controls, including `NoNewPrivileges`, filesystem protection, capability restrictions, and syscall filtering. ### Attack Path 1. An attacker obtains write access to an `openclaw` executable selected through the service's effective `PATH`, or to a directory searched before the legitimate executable. This prerequisite could arise from insecure package insta ...[truncated 1274 chars]
- Remediation
- ## Remediation Suggestions 1. Resolve the legitimate OpenClaw executable during installation and use its absolute path: ```ini ExecStart=/usr/local/bin/openclaw gateway ``` Confirm that the executable and every parent directory are owned by root and are not writable by the service account or unprivileged users. 2. Run the gateway under a dedicated unprivileged account instead of root: ```ini User=openclaw Group=openclaw WorkingDirectory=/var/lib/openclaw Environment=HOME=/var/lib/openclaw ``` 3. Grant only narrowly required capabilities if the gateway genuinely requires a privileged operation. Do not retain full root privileges solely for binding to a low port; use a reverse proxy, socket activation, or a minimal `AmbientCapabilities` setting where justified. 4. Apply systemd sandboxing appropriate to the gateway: ```ini NoNewPrivileges=true PrivateTmp=true ProtectSystem=strict ProtectHome=true ProtectKernelTunables=true ProtectKernelModules=true ProtectControlGroups=true RestrictSUIDSGID=true LockPersonality=true CapabilityBoundingSet= ReadWritePaths=/var/lib/openclaw ``` 5. Define a minimal fixed environment and avoid invoking executables through `/usr/bin/env` in a privileged service. 6. Before enabling or starting the service, verify the executable's canonical path, ownership, permissions, and integrity. Fail installation if any executable or parent directory is writable by an untrusted account. 7. Use `systemctl enable --now openclaw-gateway` only if immediate startup is intended and only after all validation and least-privilege controls have succeeded.
