T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/main.py:18
- Finding
- Hardcoded OpenClaw Gateway bearer token<![CDATA[ ## Vulnerability Details **File Location**: `scripts/main.py:18-20, 194-200`; duplicated in `scripts/team_chat_server.py:21-23, 754-767` **Vulnerability Type**: Hardcoded authentication secret **Risk Level**: High ### Vulnerable Code ```python GATEWAY_URL = "http://127.0.0.1:18789" GATEWAY_TOKEN = "9d2a452dbb739cbf940a5794181a280453dda9ed99367b6a" ``` ```python response = requests.post( f"{GATEWAY_URL}/v1/chat/completions", headers={ "Authorization": f"Bearer {GATEWAY_TOKEN}", "Content-Type": "application/json" }, json={"model": "openclaw:main", "messages": messages, "stream": False}, timeout=120 ) ``` ### Technical Analysis A live-looking bearer token is embedded directly in both server implementations. Anyone who can read the Skill package, a deployed source tree, a source archive, or repository history can recover it. The documentation states that the token should come from configuration, but the implementation does not do so. Bearer tokens grant access based solely on possession. There is no additional proof that the caller is the intended server. ### Attack Path 1. An attacker downloads or otherwise obtains the Skill source. 2. The attacker extracts `GATEWAY_TOKEN` from either Python server. 3. The attacker identifies a reachable OpenClaw gateway, such as one exposed by an unsafe deployment or port forwarding. 4. The attacker sends requests using `Authorization: Bearer <token>`. 5. Requests are processed with whatever permissions the token grants. ### Impact Assessment The attacker may invoke the associated OpenClaw gateway without application-level authorization. The exact scope depends on gateway policy, but it can include unauthorized model usage, access to gateway capabilities, consumption of resources, and impersonation of this application. Because the secret is committed in two files, deleting only one copy is insufficient. ]]>
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Revoke and rotate the exposed token immediately. 2. Remove all token copies from the current tree and repository history where feasible. 3. Load the replacement from a secret manager or environment variable: ```python GATEWAY_TOKEN = os.environ.get("GATEWAY_TOKEN") if not GATEWAY_TOKEN: raise RuntimeError("GATEWAY_TOKEN is required") ``` 4. Restrict the token to the minimum gateway permissions needed. 5. Keep the gateway bound to loopback unless remote access is explicitly secured. 6. Add automated secret scanning to CI and pre-commit workflows. 7. Ensure exceptions and logs never print authorization headers. ]]>
