T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:53
- Finding
- API Credential Exposure Through a User-Controlled API Base URL<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:53-68` **Vulnerability Type**: Credential disclosure through an unvalidated remote endpoint **Risk Level**: High ### Vulnerable Code ```markdown ### API Endpoint All requests go to the X2C Open API. The base URL is configured via `X2C_API_BASE_URL` env var or defaults to the production endpoint. Headers: - `Content-Type: application/json` - `X-API-Key: <your_x2c_api_key>` ### Get Categories ```bash curl -m 60 -X POST "$X2C_API_BASE_URL" \ -H "Content-Type: application/json" \ -H "X-API-Key: $X2C_API_KEY" \ -d '{"action": "distribution/categories", "lang": "zh-CN"}' ``` ``` ### Technical Analysis The skill instructs the agent to obtain the request destination directly from the `X2C_API_BASE_URL` environment variable and attach the sensitive `X2C_API_KEY` credential to requests sent to that destination. The supplied project does not define the expected production endpoint, require HTTPS, validate the hostname, or establish an allowlist of trusted origins. An attacker who can influence the environment variable or relevant OpenClaw configuration can redirect requests to a server under their control. Because the API key is sent in a request header, the attacker-controlled server can capture it without needing to intercept encrypted traffic. The same request pattern is documented for publishing and wallet functionality. A stolen key may therefore expose all capabilities granted to that credential rather than only the category endpoint shown above. ### Attack Path 1. The attacker influences `X2C_API_BASE_URL` through environment configuration, deployment configuration, or another configuration injection vector. 2. The value is changed to an attacker-controlled HTTP or HTTPS endpoint. 3. A user invokes any documented X2C operation. 4. The agent executes `curl` and attaches `X2C_API_KEY` to the request. 5. The attacker-controlled endpoint records the `X-API-Key` header. 6. The attacker reu ...[truncated 612 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Hard-code the official X2C HTTPS API origin when runtime endpoint customization is unnecessary. 2. If configuration is required, validate the URL before adding credentials: - Require the `https` scheme. - Require an exact approved hostname and port. - Reject embedded credentials, unexpected paths, IP-literal hosts, and unapproved subdomains. 3. Configure `curl` to reject unsafe redirects or disable redirects entirely. If redirects are required, ensure credentials are never forwarded to another origin. 4. Do not send the API key until endpoint validation has succeeded. 5. Document the canonical production endpoint in the skill rather than relying on an unspecified default. 6. Use narrowly scoped API credentials and separate publishing permissions from wallet or withdrawal permissions. 7. Rotate the API key immediately if it may previously have been transmitted to an untrusted endpoint. ]]>
