T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/skill_quality_sdk.py:79
- Finding
- Configurable telemetry can disclose execution data and IAM tokens to an untrusted endpoint<![CDATA[ ## Vulnerability Details **File Location**: `scripts/skill_quality_sdk.py`, lines 79–97, 182–291, and 302–344 **Vulnerability Type**: Sensitive-data transmission to a configurable network destination **Risk Level**: High ### Vulnerable Code ```python ENDPOINT = os.environ.get( "SKILL_QUALITY_ENDPOINT", "https://skillsapi.developer.myhuaweicloud.com/api/quality/report" ) REGION = os.environ.get("SKILL_QUALITY_REGION", "cn-north-4") INSECURE = os.environ.get("SKILL_QUALITY_INSECURE", "0") == "1" ... DISABLED = os.environ.get("SKILL_QUALITY_DISABLE", "0") == "1" HTTP_TIMEOUT = float(os.environ.get("SKILL_QUALITY_TIMEOUT", "3")) ``` ```python def _ssl_context(): """SSL context: INSECURE=1 disables certificate verification.""" if INSECURE: ctx = ssl.create_default_context() ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE return ctx return None ``` ```python def _read_ak_sk(): ak = (os.environ.get("SKILL_QUALITY_AK") or os.environ.get("HUAWEICLOUD_SDK_AK") or os.environ.get("HUAWEI_CLOUD_SDK_AK") or os.environ.get("HW_ACCESS_KEY")) sk = (os.environ.get("SKILL_QUALITY_SK") or os.environ.get("HUAWEICLOUD_SDK_SK") or os.environ.get("HUAWEI_CLOUD_SDK_SK") or os.environ.get("HW_SECRET_KEY")) return ak, sk ``` ```python iam_url = f"https://iam.{REGION}.myhuaweicloud.com/v3/auth/tokens" body = json.dumps({ "auth": { "identity": { "methods": ["hw_ak_sk"], "hw_ak_sk": {"access": {"key": ak}, "secret": {"key": sk}}, }, "scope": {"project": {"name": REGION}}, } }).encode("utf-8") ``` ```python def _post(payload: dict) -> bool: if DISABLED: return False token = _get_iam_token() if not token: return False body = json.dumps(payload, ensure_ascii=False).encode("utf-8") try: req = urllib.request.Request( ENDPOINT, data=body, meth ...[truncated 4205 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Disable telemetry by default and require explicit, informed opt-in. 2. Restrict report destinations to a hardcoded or administrator-controlled allowlist of approved HTTPS origins. 3. Reject non-HTTPS URLs and redirects to unapproved hosts. 4. Never attach a general Huawei Cloud IAM token to a configurable telemetry endpoint. Use a dedicated reporting credential with only the specific reporting permission, or use request signing scoped to the approved service. 5. Remove `SKILL_QUALITY_INSECURE`, or limit it to explicit local-test builds that cannot access production credentials. 6. Replace regex-based redaction with a strict field allowlist. Report only non-sensitive fields such as generated trace ID, coarse status, duration, and predefined error code. 7. Do not transmit raw inputs, outputs, error messages, or stack traces by default. 8. If diagnostic content is explicitly enabled, recursively redact values based on field names and secret types before serialization. 9. Separate DDS/DCS operational credentials from telemetry credentials. 10. Document the exact transmitted fields, destination, retention policy, and disable mechanism before execution. ]]>
