T03 · Remote Payload Retrieval and Execution
Error
- Location
- scripts/deploy_project.sh:4
- Finding
- Mutable Remote Repository Is Retrieved and Executed Without Verification<![CDATA[ ## Vulnerability Details **File Location**: `scripts/deploy_project.sh`, lines 4-25 **Vulnerability Type**: Remote payload retrieval and execution **Risk Level**: High ### Vulnerable Code ```bash REPO_URL="${REPO_URL:-https://github.com/JiangAgentLabs/OpenClaw-Agent-Control.git}" PROJECT_DIR="${PROJECT_DIR:-/root/OpenClaw-Agent-Control}" MONITOR_PORT="${MONITOR_PORT:-8787}" PORT="${PORT:-3000}" echo "[skill] repo: $REPO_URL" echo "[skill] project: $PROJECT_DIR" if [[ -d "$PROJECT_DIR/.git" ]]; then echo "[skill] updating existing project" git -C "$PROJECT_DIR" fetch --all --prune git -C "$PROJECT_DIR" checkout main git -C "$PROJECT_DIR" pull --ff-only origin main else echo "[skill] cloning project" git clone "$REPO_URL" "$PROJECT_DIR" git -C "$PROJECT_DIR" checkout main || true fi echo "[skill] starting backend" nohup uv run --with fastapi --with uvicorn \ python -m uvicorn app:app --app-dir "$PROJECT_DIR" --host 0.0.0.0 --port "$MONITOR_PORT" \ > /tmp/openclaw-agent-control-backend.log 2>&1 & ``` ### Technical Analysis The deployment script clones or updates the mutable `main` branch of a remote Git repository and immediately starts a Python application from that checkout. It does not pin an audited commit, validate a cryptographic checksum, verify a signed commit or tag, or inspect the retrieved files before importing the remote `app` module. The `REPO_URL` environment variable also allows the caller or execution environment to substitute an arbitrary repository. When Uvicorn loads `app:app`, Python executes module-level code in the remotely retrieved `app` module. Consequently, the effective executable payload can change after this skill package has been reviewed. ### Attack Path 1. An attacker compromises the configured upstream repository or gains the ability to influence `REPO_URL`. 2. The attacker places malicious module-level Python code in the remote application's `app` module or one of its imports. 3. An operator e ...[truncated 1002 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Pin deployment to a reviewed immutable commit SHA instead of the mutable `main` branch. - Maintain an allowlist of approved repository URLs and reject arbitrary `REPO_URL` values in production deployments. - Verify signed commits or tags against trusted maintainer keys before execution. - Validate the retrieved source against an expected cryptographic digest or approved manifest. - Separate retrieval, review, and execution into distinct steps rather than immediately starting downloaded code. - Run the application under a dedicated unprivileged service account with narrowly scoped filesystem and network permissions. - Avoid using `/root` as the default deployment directory. - Execute the application in a container or sandbox with a read-only filesystem, restricted capabilities, and controlled outbound network access. ]]>
