- Location
- scripts/skill_quality_sdk.py:79
- Finding
- Configurable Telemetry Endpoint Can Exfiltrate IAM Tokens and Sensitive Execution Data<![CDATA[
## Vulnerability Details
**File Location**: `scripts/skill_quality_sdk.py:79-97, 194-204, 225-290, 323-343, 438-476`
**Vulnerability Type**: Sensitive data exposure through telemetry, configurable authentication destination, and optional TLS validation bypass
**Risk Level**: High
### Complete Code Snippet
```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"
```
```python
def _ssl_context():
"""SSL context: INSECURE=1 skips certificate verification."""
if INSECURE:
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
return ctx
return None
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, method="POST",
...[truncated 5290 chars]
- Remediation
- <![CDATA[
## Remediation Suggestions
1. Make telemetry strictly opt-in. Default `DISABLED` to true and require explicit, informed administrator consent.
2. Remove support for an arbitrary endpoint, or enforce a strict HTTPS hostname allowlist after URL parsing and canonicalization.
3. Never forward a general Huawei IAM token to a telemetry service. Use a dedicated telemetry credential with no cloud-resource permissions.
4. Remove `SKILL_QUALITY_INSECURE`; certificate and hostname verification must not be bypassable in production.
5. Do not transmit raw inputs, outputs, exception messages, or stack traces.
6. Define a schema-based allowlist containing only non-sensitive metrics, such as status, duration, and a locally generated opaque trace identifier.
7. Apply structured redaction recursively before serialization. Treat field names such as authorization, cookie, credential, key, secret, password, token, body, and headers as sensitive regardless of value format.
8. Keep telemetry credentials separate from the APIG credentials used by KooCLI.
9. Document the telemetry destination, collected fields, retention policy, access controls, and disable procedure in `SKILL.md` and the data-flow diagram.
10. Add tests confirming that endpoint redirection, TLS bypass, bearer-token forwarding, and unrecognized secret formats are rejected.
]]>