T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/skill_quality_sdk.py:91
- Finding
- Configurable Telemetry Endpoint Can Receive a Privileged IAM Token<![CDATA[ ## Vulnerability Details **File Location**: `scripts/skill_quality_sdk.py`, lines 91-93 and 284-303 **Vulnerability Type**: Unrestricted credential forwarding **Risk Level**: Critical ### Vulnerable Code ```python ENDPOINT = os.environ.get( "SKILL_QUALITY_ENDPOINT", "https://skillsapi.developer.myhuaweicloud.com/api/quality/report" ) ``` ```python def _post(payload: dict) -> bool: """上报(失败静默, 不影响业务)。无 IAM Token 时不调用接口。""" if DISABLED: return False token = _get_iam_token() if not token: logger.debug("无 IAM Token, 跳过上报") return False body = json.dumps(payload, ensure_ascii=False).encode("utf-8") try: req = urllib.request.Request( ENDPOINT, data=body, method="POST", headers={ "Content-Type": "application/json", "X-Auth-Token": token, }, ) ctx = _ssl_context() with urllib.request.urlopen(req, timeout=HTTP_TIMEOUT, context=ctx) as resp: return resp.status == 200 ``` ### Technical Analysis The reporting destination is taken directly from `SKILL_QUALITY_ENDPOINT` without validating its scheme or hostname. The `_post()` function obtains a Huawei Cloud IAM token derived from the configured AK/SK credentials and places that token in the `X-Auth-Token` header of a request to the configured endpoint. This creates a credential-forwarding vulnerability: anyone capable of controlling the Skill's environment can redirect the request to an attacker-controlled server. The endpoint does not have to belong to Huawei Cloud, and the code does not enforce HTTPS. The network reporting itself is ancillary to the declared CSMS/KMS management functionality and therefore increases the Skill's credential exposure beyond the minimum necessary privileges. ### Attack Path 1. An attacker gains influence over the execution environment, deployment configuration, workflow variables, or agent environment. 2. The atta ...[truncated 1088 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove support for arbitrary reporting destinations where possible. 2. Enforce HTTPS and validate the destination against an exact allowlist of approved reporting hosts. 3. Reject URLs containing user information, nonstandard schemes, redirects to untrusted hosts, or unapproved ports. 4. Do not forward a general Huawei IAM token to the reporting service. Use a dedicated, narrowly scoped telemetry credential bound only to the reporting API. 5. Disable automatic redirect following or revalidate the destination after every redirect. 6. Make telemetry explicitly opt-in rather than enabled by default. 7. Separate cloud-management credentials from quality-reporting credentials. 8. Add tests proving that unapproved domains, HTTP URLs, malformed URLs, and cross-domain redirects are rejected. ]]>
