T09 · Insecure Skill Coding Practices
- Location
scripts/apm_mcp_client.py:177- Finding
Unrestricted API Endpoint Override Exposes Signed Requests to Attacker-Controlled Hosts
- Content
View full analysis
Vulnerability Details
File Location:
scripts/apm_mcp_client.py:177-181; related signing behavior inscripts/tencentcloud/common/abstract_client.py:192-225
Vulnerability Type: Unvalidated destination for authenticated network requests
Risk Level: HighVulnerable Code
python # scripts/apm_mcp_client.py:177-181 # 配置 Endpoint endpoint = os.environ.get("APM_API_ENDPOINT", DEFAULT_ENDPOINT) httpProfile = HttpProfile() httpProfile.endpoint = endpointThe selected endpoint is subsequently used when creating authenticated requests:
python # scripts/tencentcloud/common/abstract_client.py:192-225 endpoint = self._get_endpoint(options=options) timestamp = int(time.time()) cred_secret_id, cred_secret_key, cred_token = self.credential.get_credential_info() req.header["Host"] = endpoint req.header["X-TC-Action"] = action[0].upper() + action[1:] req.header["X-TC-RequestClient"] = self.request_client req.header["X-TC-Timestamp"] = str(timestamp) req.header["X-TC-Version"] = self._apiVersion if self.profile.unsignedPayload is True: req.header["X-TC-Content-SHA256"] = "UNSIGNED-PAYLOAD" if self.region: req.header['X-TC-Region'] = self.region if cred_token: req.header['X-TC-Token'] = cred_token if self.profile.language: req.header['X-TC-Language'] = self.profile.language if req.method == 'GET': params = copy.deepcopy(self._fix_params(params)) req.data = urlencode(params) elif content_type == _json_content: req.data = json.dumps(params) elif content_type == _multipart_content: boundary = uuid.uuid4().hex req.header["Content-Type"] = content_type + "; boundary=" + boundary req.data = self._get_multipart_body(params, boundary, options) service = self._service date = datetime.utcfromtimestamp(timestamp).strftime('%Y-%m-%d') signature = self._get_tc3_signature(params, req, date, service, cred_secret_key, options) auth = "TC3-HMAC-SHA256 Credential=%s/%s/%s/tc3_request, SignedHeaders=content-type;host, Si ...[truncated 2649 chars]- Remediation
View remediation
Remediation Suggestions
- Remove arbitrary endpoint overrides unless they are operationally essential.
- If private endpoints must be supported, enforce an explicit allowlist, such as:
apm.tencentcloudapi.com- Specifically approved Tencent internal APM endpoints
- Normalize and validate the endpoint before constructing the SDK client:
- Reject URL paths, query strings, fragments, embedded credentials, and non-default ports.
- Require an exact approved hostname or a carefully bounded Tencent-controlled suffix.
- Prevent suffix-confusion domains such as
apm.tencentcloudapi.com.attacker.example.
- Require HTTPS and reject any configuration that selects plain HTTP.
- Fail closed when validation fails; do not silently fall back to another destination.
- Display the resolved destination before the first authenticated call when a non-default endpoint is selected.
- Treat responses from non-public or development endpoints as untrusted data.
- Prefer short-lived, least-privilege credentials limited to the required APM actions.
- Add tests for malicious endpoints, URL user information, Unicode hostname confusion, suffix confusion, ports, and malformed host values.
