T09 · Insecure Skill Coding Practices
Error
- Location
- clawmarket-cli.sh:5
- Finding
- API Credential Disclosure Through Unrestricted Custom Base URL<![CDATA[ ## Vulnerability Details **File Location**: `clawmarket-cli.sh`, lines 5–9 **Vulnerability Type**: Unvalidated endpoint override leading to credential disclosure **Risk Level**: High ### Vulnerable Code ```bash BASE_URL="${CLAWMARKET_URL:-https://market.aladdn.app/api}" API_KEY="${CLAWMARKET_API_KEY:-}" headers=(-H "Content-Type: application/json") [ -n "$API_KEY" ] && headers+=(-H "X-API-Key: $API_KEY") ``` ### Technical Analysis The CLI permits `CLAWMARKET_URL` to replace the trusted production API endpoint with an arbitrary URL. It does not validate the URL scheme, hostname, port, or path before constructing the shared request headers. When `CLAWMARKET_API_KEY` is set, the credential is added to requests regardless of their destination. Consequently, an attacker who can influence the process environment, a wrapper script, shell initialization configuration, CI/CD variables, or command-launch instructions can redirect authenticated requests to an attacker-controlled server. The override can also use plaintext HTTP, exposing the API key to network interception. The custom endpoint capability may be useful for legitimate testing, but forwarding production credentials to arbitrary origins exceeds the minimum privileges required for normal marketplace operation. ### Attack Path 1. The victim has a valid API key in `CLAWMARKET_API_KEY`. 2. An attacker causes `CLAWMARKET_URL` to reference an attacker-controlled endpoint, for example through a malicious wrapper, poisoned environment configuration, or deceptive execution instructions. 3. The victim invokes an authenticated operation such as `sell`, `buy`, `order`, or `domain-buy`. 4. The script constructs the `X-API-Key` header without checking the destination. 5. `curl` sends the API key to the attacker-controlled server. 6. The attacker captures and reuses the key against the legitimate ClawMarket API. ### Impact Assessment Successful exploitation discloses the victim's ClawMarket API key. The ...[truncated 562 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Pin authenticated production requests to `https://market.aladdn.app/api`. 2. Parse and validate any configurable endpoint before use: - Require HTTPS. - Allow only explicitly approved hostnames and ports. - Reject embedded credentials, unexpected schemes, and malformed URLs. 3. Attach `X-API-Key` only when the parsed destination exactly matches a trusted allowlisted origin. 4. If custom endpoints are needed for development, require an explicit opt-in flag such as `CLAWMARKET_ALLOW_CUSTOM_URL=1`. 5. Do not forward production credentials when custom-endpoint mode is enabled; require a separate development credential variable. 6. Configure `curl` with secure failure behavior, such as `--fail-with-body --show-error`, and explicitly constrain allowed protocols using `--proto '=https'`. 7. Document that environment variables affecting security-sensitive destinations must not be accepted from untrusted wrappers, repositories, or CI configuration. A safe design should independently validate the destination before creating or attaching authentication headers. ]]>
