Back to skill

Security audit

Host Hardening

Security checks for vulnerabilities and agentic risk

Overview

This host-hardening skill contains useful security steps, but it also creates a persistent root-level OpenClaw gateway service that is not clearly scoped or justified by the stated hardening purpose.

Review this skill carefully before installing. The basic hardening commands may be useful, but run them only from a confirmed key-based SSH session and ensure required ports are allowed before enabling UFW. Do not install the openclaw-gateway service as written unless you intentionally want that persistent service, have verified the exact executable path and ownership, and have changed it to run under a dedicated least-privileged account with systemd hardening.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T05 · Unauthorized Access and Privilege Escalation

Error
Location
SKILL.md:46
Finding

Persistent Gateway Service Runs a PATH-Resolved Executable as Root

Content
View full analysis

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
View 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.

Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (7)

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The skill makes disruptive security changes to SSH and the firewall without an upfront warning about lockout risk, sequencing requirements, or service interruption. Although a later note mentions verifying key-based access, the lack of prominent preconditions increases the chance an operator will cut off remote administration.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
80% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · SKILL.md (reported line 33)May include surrounding context.

bash
apt-get install -y fail2ban
systemctl enable --now fail2ban

Default config protects SSH. For custom jails: /etc/fail2ban/jail.local.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
80% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · SKILL.md (reported line 41)May include surrounding context.

OpenClaw Credentials

bash
chmod 700 ~/.openclaw/credentials

OpenClaw Gateway Service

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill’s stated purpose is host hardening, but it also creates and enables a new persistent OpenClaw gateway service. That expands scope from defensive configuration into software deployment and persistence, which can introduce unintended exposure and privileged execution paths not necessary for hardening.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The systemd unit persists openclaw gateway across reboots and runs it as root, which is not justified by the hardening objective. If the gateway binary, environment, or working directory is compromised, this creates a durable root-level execution mechanism with substantial privilege and persistence.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
96% confidence
Finding

Enabling the newly created openclaw-gateway service at boot establishes persistent execution of an application unrelated to core host hardening. Because the associated unit runs as root, the persistence materially increases risk by ensuring privileged code starts automatically after reboot.

Content

Scanner excerpt · SKILL.md (reported line 65)May include surrounding context.

[Install] WantedBy=multi-user.target EOF systemctl daemon-reload && systemctl enable openclaw-gateway

text

## Verify

Session Persistence

Medium
Category
Rogue Agent
Confidence
80% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · SKILL.md (reported line 75)May include surrounding context.

systemctl is-active fail2ban # active grep PasswordAuthentication /etc/ssh/sshd_config # no stat -c %a ~/.openclaw/credentials # 700 systemctl is-enabled openclaw-gateway # enabled

text

## Lessons