T03 · Remote Payload Retrieval and Execution
Error
- Location
- install.py:13
- Finding
- Unverified Remote Python Payload Download and Execution<![CDATA[ ## Vulnerability Details **File Location**: `install.py:13-49` **Vulnerability Type**: Unverified remote code retrieval and execution **Risk Level**: Critical ### Vulnerable Code ```python REPO_URL = "https://raw.githubusercontent.com/adminlove520/openclaw-gateway-watchdog-v2/main/gateway_watchdog.py" def download_watchdog(): """下载 gateway_watchdog.py""" script_path = Path(__file__).parent.resolve() / "gateway_watchdog.py" if script_path.exists(): print(f"✅ gateway_watchdog.py 已存在") return script_path print("📥 正在下载 gateway_watchdog.py...") try: urllib.request.urlretrieve(REPO_URL, script_path) print(f"✅ 下载完成: {script_path}") return script_path except Exception as e: print(f"❌ 下载失败: {e}") return None def main(): print("=" * 50) print("🚀 OpenClaw Gateway 7/24 运行") print("=" * 50) # 1. 下载脚本 script_path = download_watchdog() if not script_path: sys.exit(1) # 2. 启动 watchdog print("\n🚀 启动 Gateway Watchdog...") try: result = subprocess.run( [sys.executable, str(script_path), "start"], capture_output=True, text=True ) ``` ### Technical Analysis When the local `gateway_watchdog.py` file does not exist, the installer downloads a replacement from the mutable `main` branch of a personal GitHub repository. The retrieved content is accepted without a cryptographic hash check, digital-signature verification, immutable commit pin, or source-content validation. The downloaded file is then passed directly to the current Python interpreter. Consequently, the effective code executed by the Skill can change after the reviewed package has been published. HTTPS protects transport in normal circumstances but does not protect against repository compromise, malicious upstream changes, account takeover, or an unauthorized maintainer update. The URL in `install.py` also ref ...[truncated 1798 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove the network fallback and execute only the `gateway_watchdog.py` file included in the reviewed Skill package. 2. Treat a missing bundled script as an installation error rather than silently replacing it with remote code. 3. If remote retrieval is operationally necessary: - Pin the URL to an immutable commit rather than the mutable `main` branch. - Publish and hard-code a trusted SHA-256 digest for the expected file. - Verify the digest before writing or executing the file. - Prefer a signed release artifact and validate its signature against a trusted, pinned public key. - Download into a securely created temporary file, validate it, and only then atomically move it into place. 4. Require explicit user confirmation before executing newly downloaded code. 5. Make the repository URL consistent with the documented official source. 6. Fail closed and delete the downloaded file if any integrity, signature, size, or content check fails. 7. Run the watchdog under a dedicated, non-privileged account and explicitly warn users not to execute the installer as root or administrator. ]]>
