T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/capabilities/configure/service.py:35
- Finding
- Configurable Gateway Endpoint Can Exfiltrate AK and Gateway Bearer Credentials<![CDATA[ ## Vulnerability Details **File Location**: `scripts/capabilities/configure/service.py`, lines 35–53 **Vulnerability Type**: Untrusted endpoint override and plaintext credential transmission **Risk Level**: High ### Vulnerable Code ```python gateway_url = os.environ.get("OPENCLAW_GATEWAY_URL", "http://localhost:18789") token = os.environ.get("OPENCLAW_GATEWAY_TOKEN", "") payload = { "skills": { "entries": { SKILL_NAME: { "apiKey": api_key } } } } try: headers = {} if token: headers["Authorization"] = "Bearer {}".format(token) resp = requests.patch("{}/api/config".format(gateway_url), headers=headers, json=payload, timeout=5) return resp.ok ``` ### Technical Analysis `OPENCLAW_GATEWAY_URL` is accepted without validating its scheme, hostname, port, or destination. The configured API key is then placed in the request body, while `OPENCLAW_GATEWAY_TOKEN` is placed in the `Authorization` header. Consequently, a caller that can influence the process environment can redirect both credentials to an arbitrary server. The implementation also permits plaintext HTTP URLs, including the default local URL, without checking that a non-loopback destination uses HTTPS. This behavior exceeds the minimum privileges required for configuring the local OpenClaw gateway. A local configuration operation should only communicate with a trusted loopback or explicitly allowlisted endpoint. ### Attack Path 1. An attacker, malicious launcher, or prompt-injected automation influences the environment used to execute the Skill. 2. The attacker sets `OPENCLAW_GATEWAY_URL` to an attacker-controlled endpoint, for example `http://attacker.example`. 3. The user invokes the AK configuration workflow. 4. `configure_via_gateway()` sends a PATCH request to the attacker-controlled endpoint. 5. The request discloses: - The complete AK in the JSON body. - The OpenClaw g ...[truncated 663 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove arbitrary endpoint overrides in production builds. 2. Restrict configuration requests to a fixed loopback endpoint or a strict allowlist. 3. Parse the endpoint with `urllib.parse.urlparse()` and enforce: - `https` for remote destinations. - `http` only for `localhost`, `127.0.0.1`, or an approved Unix-domain transport. - Approved ports and no embedded user information. 4. Do not send `OPENCLAW_GATEWAY_TOKEN` to any endpoint that has not passed destination validation. 5. Prefer a Unix-domain socket or authenticated local IPC for gateway configuration. 6. Fail closed instead of falling back after endpoint validation or TLS errors. 7. Add tests proving that external HTTP URLs, DNS rebinding targets, link-local addresses, and non-allowlisted hosts are rejected. 8. Rotate both the AK and gateway token if an untrusted endpoint may previously have been configured. ]]>
