T09 · Insecure Skill Coding Practices
- Location
scripts/kb_connector.py:18- Finding
Bearer credentials can be transmitted to arbitrary or plaintext endpoints
- Content
View full analysis
Vulnerability Details
File Location:
scripts/kb_connector.py:18-33,scripts/kb_connector.py:55-59, andscripts/kb_connector.py:87-91
Vulnerability Type: Unrestricted credential transmission
Risk Level: MediumVulnerable Code
python def __init__(self, base_url: str, api_key: Optional[str] = None): """ Initialize the knowledge base connector Args: base_url: The base URL of the knowledge base API api_key: Optional API key for authentication """ self.base_url = base_url.rstrip('/') self.headers = { 'Content-Type': 'application/json' } if api_key: self.headers['Authorization'] = f'Bearer {api_key}' def health_check(self) -> bool: """Check if the knowledge base API is accessible""" try: response = requests.get(f"{self.base_url}/health", headers=self.headers) return response.status_code == 200 except Exception: return FalseThe same authorization headers are used for search and chat requests:
python response = requests.post( f"{self.base_url}/api/search", headers=self.headers, json=search_payload )python response = requests.post( f"{self.base_url}/api/chat", headers=self.headers, json=chat_payload )Technical Analysis
The caller controls
base_url, and the script does not validate its scheme, hostname, port, or resolved network destination. When an API key is provided, the script places it in a reusableAuthorizationheader and sends that header to every endpoint, including the health-check endpoint.Consequently, the connector permits bearer credentials to be transmitted over plaintext HTTP or to an attacker-controlled host. The health check also sends authentication material even though many health endpoints do not require authentication. No request timeout or explicit redirect policy i ...[truncated 1414 chars]
- Remediation
View remediation
Remediation Suggestions
- Require
https://for all authenticated endpoints and reject plaintext HTTP when an API key is configured. - Parse URLs with
urllib.parseand reject user-info, unsupported schemes, unexpected ports, fragments, and malformed hostnames. - Support an explicit hostname allowlist for deployments that use known knowledge-base services.
- Do not send authorization headers to health endpoints unless authentication is explicitly required.
- Disable automatic redirects or validate every redirect destination before forwarding credentials.
- Add finite connection and response timeouts, for example:
python requests.post(url, headers=headers, json=payload, timeout=(5, 30), allow_redirects=False) - Document that API credentials must only be used with trusted endpoints.
- Where practical, use separate, narrowly scoped credentials for search and chat operations.
- Require
