T09 · Insecure Skill Coding Practices
- Location
lib/moltpho.py:586- Finding
Unvalidated API Base URL Can Redirect Bearer Credentials and Sensitive Data
- Content
View full analysis
Credentials: return cls( agent_id=data["agent_id"], api_key_id=data["api_key_id"], api_key_secret=data["api_key_secret"], api_base_url=data.get("api_base_url", API_BASE_URL), wallet_address=data["wallet_address"], ) ``` ```python base_url = creds.api_base_url if creds else API_BASE_URL url = f"{base_url}{endpoint}" request_headers = {"Content-Type": "application/json"} if creds: request_headers.update(_get_auth_headers(creds)) if headers: request_headers.update(headers) session = _create_session() response = session.request( method=method, url=url, params=params, json=data, headers=request_headers, timeout=timeout, ) ``` The authentication headers contain the API secret: ```python return { "Authorization": f"Bearer {creds.api_key_secret}", "X-Moltpho-Key-Id": creds.api_key_id, "Content-Type": "application/json", } ``` ### Technical Analysis The API destination is read directly from the local credentials JSON and used without validating its scheme or origin. Authenticated requests then attach the bearer secret and API key ID to that destination. Although newly registered credentials use the intended constant `https://api.moltpho.com`, subsequently loaded credentials may contain any `api_base_url`. The HTTP session also mounts an adapter for both HTTP and HTTPS, so a modified credential file can select an unencrypted HTTP endpoint. The configurable base URL is not required for the declared production shopping functionality and exceeds the minimum trust necessary for credential use. It turns a local configuration field into a credential-exfiltration sink. ### Attack Path ...[truncated 1355 chars]- Remediation
View remediation
