T09 · Insecure Skill Coding Practices
- Location
hub_client.py:53- Finding
API Credentials and Message Data Can Be Transmitted over Plaintext HTTP
- Content
View full analysis
Vulnerability Details
File Location:
hub_client.py:53, 62-66, 71-74; identical code inmessage_hub.py:53, 62-66, 71-74
Vulnerability Type: Cleartext transmission of sensitive information
Risk Level: MediumVulnerable Code
python self.base_url = base_url or os.getenv("MESSAGE_HUB_URL", "http://localhost:8000") self.api_key = api_key or os.getenv("MESSAGE_HUB_API_KEY") self.sender = sender or os.getenv("MESSAGE_HUB_SENDER", "Unknown") self.retry_times = retry_times self.retry_delay = retry_delay if not self.api_key: raise ValueError("API Key must be configured") self.session = requests.Session() self.session.headers.update({ "Content-Type": "application/json", "X-API-Key": self.api_key })python def _request(self, method: str, endpoint: str, data: Optional[Dict] = None) -> Dict: """Send an HTTP request with retries.""" url = f"{self.base_url}{endpoint}" for attempt in range(self.retry_times): try: response = self.session.request(method, url, json=data, timeout=30) response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: if attempt == self.retry_times - 1: raise RetryError(f"Request failed after {self.retry_times} attempts: {e}") time.sleep(self.retry_delay * (attempt + 1))The insecure configuration is also promoted in the examples at
README.md:23, 39, 111, 120, 144.Technical Analysis
The client accepts arbitrary HTTP endpoints and defaults to an
http://URL. Every request made through the session includes theX-API-Keycredential. Push requests also contain message contents, sender identities, recipients, and other potentially sensitive metadata.HTTP provides neither transport confidentiality nor server authentication. Although the default loopback address is less exposed, the ...[truncated 1824 chars]
- Remediation
View remediation
Remediation Suggestions
- Require HTTPS for every non-loopback Message Hub endpoint.
- Parse and validate
base_urlduring initialization. Rejecthttp://unless the hostname is explicitly verified as a loopback address and insecure development mode has been deliberately enabled. - Preserve the default TLS certificate and hostname verification behavior of
requests; do not introduceverify=False. - Change documentation and examples to use
https://for all non-local deployments. - Consider requiring an explicit option such as
allow_insecure_localhost=Truefor local HTTP development rather than silently permitting plaintext transport. - Rotate any API key that may previously have been sent over an untrusted plaintext connection.
- Use narrowly scoped API keys with expiration, revocation, and per-operation authorization to reduce the impact of credential theft.
- Consider using mutual TLS or another strong client-authentication mechanism for high-trust deployments.
