T09 · Insecure Skill Coding Practices
Warning
- Location
- SKILL.md:66
- Finding
- Bearer Credential Forwarded to an Unvalidated Configurable Endpoint<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 66–78 **Vulnerability Type**: Unvalidated API endpoint and credential disclosure **Risk Level**: Medium ### Vulnerable Code ```bash # 1. 读取配置 / Read config WORKFLOW_ID=$(jq -r '.workflow_id' ~/.openclaw/skills/image_gen_coze/config.json) COZE_CONFIG=~/.openclaw/skills/coze_workflow/config.json API_KEY=$(jq -r '.api_key' "$COZE_CONFIG") BASE_URL=$(jq -r '.base_url // "https://api.coze.cn"' "$COZE_CONFIG") # 2. 构建 prompt / Build prompt PROMPT="一只可爱的橘猫在窗台上晒太阳,温暖的光线,写实摄影风格 --ar 1:1" # 3. 调用 coze_workflow 执行 / Execute result=$(curl -s -X POST "${BASE_URL}/v1/workflow/stream_run" \ -H "Authorization: Bearer ${API_KEY}" \ -H "Content-Type: application/json" \ ``` ### Technical Analysis The documented implementation obtains both `api_key` and `base_url` from the dependency configuration. It then sends the API key in an `Authorization: Bearer` header to the configured endpoint without validating its scheme or hostname. This creates a credential-forwarding weakness. Any party capable of modifying `~/.openclaw/skills/coze_workflow/config.json` can replace `base_url` with an attacker-controlled URL. The next invocation will disclose the bearer credential and submitted prompt to that server. A non-HTTPS endpoint could also expose these values to network interception. This issue does not independently grant configuration-file modification privileges. Exploitation requires influence over the dependency configuration or another mechanism that controls `base_url`. ### Attack Path 1. An attacker obtains the ability to alter the Coze dependency configuration. 2. The attacker sets `base_url` to an endpoint under their control, such as `https://attacker.example`. 3. A user or agent invokes the image-generation workflow. 4. The Skill constructs a request to `https://attacker.example/v1/workflow/stream_run`. 5. The request includes the victim's Coze API key in the bearer authorization header. 6. The ...[truncated 647 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Reject endpoint values that do not use HTTPS. 2. Parse the endpoint and enforce an explicit hostname allowlist, such as `api.coze.cn`. 3. Do not send credentials to arbitrary endpoints selected from a mutable configuration file. 4. Associate each credential with a fixed approved service origin. 5. Reject URLs containing user information, unexpected ports, malformed hosts, or IP-address literals unless explicitly required. 6. Configure redirects conservatively and ensure authorization headers are never forwarded to a different origin. 7. Restrict dependency-configuration permissions so only the owning user can read or modify the file. 8. Fail closed when the endpoint is missing or invalid instead of silently accepting an untrusted value. ]]>
