T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/send_email.py:6
- Finding
- Caller-Controlled API Endpoint Can Expose EngageLab Credentials## Vulnerability Details **File Location**: `scripts/send_email.py`, lines 6-16 and 60 **Vulnerability Type**: Unrestricted destination for authenticated network requests **Risk Level**: High ### Vulnerable Code ```python def send_engagelab_email(api_user, api_key, from_address, to_addresses, subject, html_content=None, text_content=None, preview_text=None, cc_addresses=None, bcc_addresses=None, reply_to_addresses=None, vars_data=None, dynamic_vars_data=None, label_id=None, label_name=None, headers=None, attachments=None, settings=None, custom_args=None, request_id=None, data_center_url="https://email.api.engagelab.cc"): # Default to Singapore data center auth_string = f"{api_user}:{api_key}" encoded_auth = base64.b64encode(auth_string.encode('utf-8')).decode('utf-8') url = f"{data_center_url}/v1/mail/send" headers = { "Content-Type": "application/json;charset=utf-8", "Authorization": f"Basic {encoded_auth}" } # ... response = requests.post(url, headers=headers, data=json.dumps(payload)) ``` ### Technical Analysis The function accepts an unrestricted `data_center_url` and sends an HTTP Basic Authorization header to the resulting URL. It does not require HTTPS or verify that the normalized destination hostname belongs to EngageLab. Base64 is the encoding required by HTTP Basic authentication and is not encryption. Anyone controlling the destination server can decode the header and recover `api_user` and `api_key`. Allowing arbitrary destinations is unnecessary because the documented API specification identifies fixed EngageLab data-center endpoints. This behavior exceeds minimum privilege: the Skill needs network access to EngageLab's email API, but it does not need permission to disclose credentials to arbitrary caller-selected hosts. ### Attack Path 1 ...[truncated 1275 chars]
- Remediation
- ## Remediation Suggestions - Replace free-form `data_center_url` input with an enumeration of supported regions mapped internally to exact documented endpoints. - Allow only normalized HTTPS URLs whose host and port exactly match an explicit allowlist, such as: - `email.api.engagelab.cc` - `emailapi-tr.engagelab.com` - Reject embedded credentials, unexpected ports, redirects to unapproved hosts, non-HTTPS schemes, and hostname suffix tricks. - Disable redirects or validate every redirect destination before forwarding the Authorization header. - Keep TLS certificate verification enabled. - Prefer a scoped and revocable credential with only the permissions required to send email. - Add tests confirming that arbitrary, malformed, non-HTTPS, and look-alike destinations are rejected before any request is sent.
