Skip to content

security: Command injection risk in verify.sh openclaw port check #3070

@louisgv

Description

@louisgv

Summary

The _openclaw_ensure_gateway and _openclaw_restart_gateway functions in sh/e2e/lib/verify.sh contain command injection risks through unsafe variable interpolation in the port check logic.

Location

  • File: sh/e2e/lib/verify.sh
  • Lines: 82, 106

Vulnerability Details

The port_check variable contains shell code that is later interpolated into a remote command without proper escaping:

# Line 82 in _openclaw_ensure_gateway:
local port_check='ss -tln 2>/dev/null | grep -q ":18789 " || (echo >/dev/tcp/127.0.0.1/18789) 2>/dev/null || nc -z 127.0.0.1 18789 2>/dev/null'

# Line 86 - used in remote command:
if ${port_check}; then

While the current code only uses hardcoded values, the pattern is unsafe because:

  1. The variable is interpolated directly into the remote command string
  2. If this pattern is copied or modified to accept dynamic input, it becomes exploitable
  3. Shell metacharacters in the port_check variable would execute on the remote system

Severity

HIGH - Command injection pattern, though currently only using hardcoded values

Recommendation

Use a function-based approach or ensure the port check logic is properly escaped if it needs to be dynamic.

-- security/shell-scanner

Metadata

Metadata

Assignees

No one assigned

    Labels

    safe-to-workSecurity triage: safe for automated processing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions