T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:162
- Finding
- API Key May Be Disclosed to an Arbitrary Configurable Endpoint## Vulnerability Details **File Location**: `SKILL.md:162-164` **Vulnerability Type**: Unrestricted credential forwarding **Risk Level**: High ### Vulnerable Code ```text - **API key**: Env `ZCLAW_API_KEY`, or `ZCLAW_API_KEY` in `~/.zclaw/config.json` (see path note below). The bridge also accepts the key via header `X-ZClaw-Api-Key` or body `apiKey`. - **Base URL**: `ZCLAW_BASE_URL` or `ZINIAO_ZCLAW_BASE_URL` (default `http://127.0.0.1:9481`). - **First time / Rotate key**: Obtain a ZClaw API key from your server or Ziniao Ecosystem Center. You can configure it via conversation, environment, configuration file, or an installation script. ``` The invocation workflow further directs the Agent to include the resolved key in every invocation request. ### Technical Analysis Authentication is necessary for the declared browser-bridge functionality. However, the Skill independently resolves the API key and destination URL, then forwards the key to the configured destination without requiring that the endpoint remain on loopback, use HTTPS, or match a trusted hostname. The environment variables `ZCLAW_BASE_URL` and `ZINIAO_ZCLAW_BASE_URL` therefore act as credential-routing controls. If either variable or the corresponding configuration is modified by an attacker, authenticated requests can be redirected away from the intended local bridge. This exceeds minimum privilege because the Skill only needs to disclose the credential to a known Ziniao bridge, not to an arbitrary environment-selected HTTP origin. The documented default also uses plaintext HTTP, which is acceptable for a strictly loopback-only service but unsafe if the same scheme is used with a remote host. ### Attack Path 1. An attacker with influence over the Agent's environment or ZClaw configuration sets `ZCLAW_BASE_URL` or `ZINIAO_ZCLAW_BASE_URL` to an attacker-controlled endpoint. 2. The Skill resolves `ZCLAW_API_KEY` from the conversation, environment, or `~/.zc ...[truncated 1010 chars]
- Remediation
- ## Remediation Suggestions 1. Restrict the default configuration to loopback addresses such as `127.0.0.1` and `::1`. 2. Reject non-loopback destinations unless the user explicitly enables remote bridge access. 3. For remote access, require HTTPS and validate the certificate and expected hostname. 4. Maintain an explicit allowlist of trusted bridge origins and bind each credential to a specific origin. 5. Reject URLs containing user information, unexpected ports, fragments, or non-HTTP protocols. 6. Do not forward credentials across redirects; either disable redirects or revalidate the destination after every redirect. 7. Display the destination origin and request confirmation before first sending a key to a newly configured remote endpoint. 8. Use a narrowly scoped bridge token with expiration, rotation, and per-tool authorization where supported.
