T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/maker_api.py:20
- Finding
- JWT Disclosure Through Unrestricted Custom API Base URL<![CDATA[ ## Vulnerability Details **File Location**: `scripts/maker_api.py:20-45` **Vulnerability Type**: Arbitrary credential destination / insufficient endpoint validation **Risk Level**: High ### Vulnerable Code ```python def build_env_config(env: str, base_url: Optional[str], jwt_token: str) -> EnvConfig: """Resolve final base URL from env / override.""" if not jwt_token: raise SystemExit("jwt_token is required for Maker API calls.") if base_url: return EnvConfig(base_url=base_url.rstrip("/"), jwt_token=jwt_token) if env == "test": return EnvConfig(base_url="https://api-qa.proto.stove.finance", jwt_token=jwt_token) # default: production return EnvConfig(base_url="https://proto.stove.finance", jwt_token=jwt_token) def _build_request(url: str, method: str, cfg: EnvConfig, body: Optional[Dict[str, Any]] = None) -> request.Request: if body is not None: data = json.dumps(body).encode("utf-8") else: data = None req = request.Request(url, method=method, data=data) req.add_header("Content-Type", "application/json") req.add_header("Authorization", f"Bearer {cfg.jwt_token}") return req def http_call(req: request.Request) -> Dict[str, Any]: """Perform HTTP request and return parsed JSON.""" try: with request.urlopen(req, timeout=20) as resp: ``` ### Technical Analysis The `--base-url` override is accepted without validating its scheme, hostname, port, or trust relationship. Every request constructed from this URL receives the user's complete bearer JWT in the `Authorization` header. Consequently, the token can be sent directly to an attacker-controlled domain or over plaintext HTTP. The default production and test destinations are legitimate HTTPS endpoints, and authenticated network traffic is required by the Skill's declared purpose. However, unrestricted credential forwarding to any caller-selected endpoint exceeds the minimum privileges necessary. ...[truncated 1367 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove arbitrary production overrides or restrict them to an explicit allowlist: - `proto.stove.finance` - `api-qa.proto.stove.finance` 2. Require the URL scheme to be exactly `https`. 3. Reject embedded credentials, fragments, unexpected ports, IP literals, and malformed hostnames. 4. Resolve and compare normalized hostnames rather than using suffix matching. 5. Disable redirects or implement a redirect handler that rejects cross-origin and HTTPS-to-HTTP redirects. 6. Do not attach the JWT until the final destination has passed validation. 7. If custom development endpoints are necessary, require a separate explicit unsafe-development flag and do not reuse production JWTs with them. 8. Add tests confirming that HTTP URLs, unapproved domains, deceptive subdomains, and cross-origin redirects are rejected. ]]>
