Back to skill

Security audit

huawei-cloud-apig-instance-management

Security checks for vulnerabilities and agentic risk

Overview

This APIG management skill is mostly coherent, but it bundles an undisclosed telemetry SDK that can send IAM-authenticated execution data off-box and its setup guidance relies on mutable installers.

Install only after reviewing or removing scripts/skill_quality_sdk.py, disabling any telemetry by default, pinning and verifying KooCLI installation artifacts, and narrowing Huawei IAM permissions to the exact APIG actions and resources you intend the agent to manage. Use read-only credentials unless you explicitly need create/update/delete operations, and avoid exposing AK/SK credentials in environments where SKILL_QUALITY_ENDPOINT or SKILL_QUALITY_INSECURE could be set unexpectedly.

Vulnerability Patterns
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
Findings (3)

T09 · Insecure Skill Coding Practices

Error
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. ]]>

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
references/iam-policies.md:43
Finding
Recommended IAM Management Policy Grants Permissions Beyond Declared Skill Operations<![CDATA[ ## Vulnerability Details **File Location**: `references/iam-policies.md:43-57` **Vulnerability Type**: Excessive cloud permissions and failure to enforce least privilege **Risk Level**: Medium ### Complete Code Snippet ```json { "Version": "1.1", "Statement": [ { "Effect": "Allow", "Action": [ "apig:instance:create", "apig:instance:delete", "apig:instance:update", "apig:instance:bindEip", "apig:group:create", "apig:group:delete", "apig:group:update", "apig:api:create", "apig:api:update", "apig:api:delete", "apig:api:publish", "apig:throttle:create", "apig:throttle:update", "apig:throttle:delete" ], "Resource": "*" } ] } ``` ### Technical Analysis The Skill declares a fixed set of 17 actions. Its throttling functionality supports creating and listing policies, but it does not declare throttling-policy update or deletion. It also explicitly states that API group update or rename is outside the Skill’s scope. Nevertheless, the recommended policy grants: - `apig:instance:update` - `apig:group:update` - `apig:throttle:update` - `apig:throttle:delete` These permissions are not required by the documented operations. The policy also applies the permissions to `"Resource": "*"`, providing no resource-level restriction in the example. User confirmation in `SKILL.md` is an operational safeguard, not an access-control boundary. It does not prevent another process, injected instruction, compromised Agent, or stolen IAM token from directly exercising the excess permissions. ### Attack Path 1. An administrator follows `references/iam-policies.md` and assigns the management policy to the Agent’s Huawei Cloud identity. 2. The identity receives update and deletion permissions not required by the declared Skill actions. 3. The Agent is compromised, receives malicious untrusted instructions, or has its IAM token ex ...[truncated 1121 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Remove `apig:group:update`, `apig:throttle:update`, and `apig:throttle:delete` because the Skill does not declare corresponding operations. 2. Remove `apig:instance:update` unless a documented action demonstrably requires it. 3. Create separate policies for: - Read-only analysis. - Resource creation. - API updates and publishing. - Destructive deletion. 4. Grant destructive permissions only through temporary elevation after explicit user approval. 5. Restrict policy resources, regions, projects, and enterprise projects wherever Huawei IAM supports such conditions. 6. Use a dedicated cloud identity for the Skill rather than a general administrator identity. 7. Add automated tests that compare the documented action inventory with the IAM action list and fail when undocumented permissions are introduced. 8. Clarify that predefined administrator roles are not the preferred option when a narrower custom policy is available. ]]>

T03 · Remote Payload Retrieval and Execution

Warning
Location
references/cli-installation-guide.md:6
Finding
Installation Guide Executes Mutable Remote Code and Uses Unpinned Dependencies<![CDATA[ ## Vulnerability Details **File Location**: `references/cli-installation-guide.md:6-20` **Vulnerability Type**: Unverified remote installer execution and unpinned dependency installation **Risk Level**: Medium ### Complete Code Snippet ```bash # Linux x86_64 curl -sSL https://cn-north-4-hww-cloud-download.obs.cn-north-4.myhuaweicloud.com/cli/hcloud_install.sh -o hcloud_install.sh bash hcloud_install.sh # Or via Python package manager pip3 install huaweicloudcli ``` ```bash hcloud update -y ``` ### Technical Analysis The installation guide downloads a shell script from a remote URL and executes it without validating a cryptographic signature, checksum, expected version, or immutable artifact identifier. The effective installer payload can therefore change after the Skill has been reviewed. The alternative Python installation also omits a version constraint and integrity hash. Consequently, the installed package depends on whichever release the package index resolves at execution time. The guide additionally recommends `hcloud update -y`, which performs an unattended update without identifying or verifying the target version. Although the referenced domains and package name appear related to Huawei Cloud, source reputation does not replace artifact integrity verification or reproducible version pinning. This finding concerns instructions a user must execute manually; the bundled Python SDK does not itself run these installation commands. ### Attack Path 1. A user follows the prerequisite installation instructions. 2. The remote installer object, package-index release, update metadata, hosting account, or distribution channel is compromised or unexpectedly changed. 3. The user downloads the altered installer or package without a pinned version or trusted integrity value. 4. The user executes the shell script or installs the resolved Python package. 5. The altered code runs with the privileges of the invoking user and may install or replace the ...[truncated 975 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Pin an explicitly tested KooCLI or `huaweicloudcli` version. 2. Publish an expected SHA-256 or stronger digest for every downloadable artifact. 3. Prefer vendor-signed packages and verify the signature against a documented trusted key. 4. Replace direct script execution with download, integrity verification, inspection, and then execution. 5. For Python installation, use an exact version and hashes, for example through a locked requirements file with `--require-hashes`. 6. Avoid unattended `hcloud update -y` in production or Agent environments. 7. Test new versions in an isolated environment before updating operational systems. 8. Run installation as an unprivileged user where possible and do not expose cloud credentials during installation. 9. Record the approved source URL, package version, hash, release date, and verification procedure in the guide. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (10)

Tainted flow: 'req' from os.environ.get (line 283, credential/environment) → urllib.request.urlopen (network output)

Critical
Category
Data Flow
Content
headers={"Content-Type": "application/json"},
        )
        ctx = _ssl_context()
        with urllib.request.urlopen(req, timeout=HTTP_TIMEOUT + 5, context=ctx) as resp:
            if resp.status != 201:
                logger.warning("IAM Token 获取失败: HTTP %d", resp.status)
                return None
Confidence
90% confidence
Finding
Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.

Tainted flow: 'req' from os.environ.get (line 283, credential/environment) → urllib.request.urlopen (network output)

Critical
Category
Data Flow
Content
},
        )
        ctx = _ssl_context()
        with urllib.request.urlopen(req, timeout=HTTP_TIMEOUT, context=ctx) as resp:
            return resp.status == 200
    except Exception as e:
        logger.warning("skill quality report failed: %s", e)
Confidence
94% confidence
Finding
The SDK posts execution telemetry, including masked inputs, outputs, and stack traces, to an endpoint that is fully overrideable via the SKILL_QUALITY_ENDPOINT environment variable. That creates an exfiltration path where sensitive runtime data can be sent to an attacker-controlled host if the environment is manipulated, which is especially risky because this skill's stated purpose is APIG management, not telemetry export.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding
The documented purpose is APIG management, but the finding indicates additional hidden behavior including telemetry uploads, self-check calls to a remote reporting service, execution metadata collection, and IAM token acquisition using AK/SK credentials. This is dangerous because it creates undisclosed data flows involving sensitive cloud credentials and operational metadata, which could enable credential misuse, surveillance, or exfiltration outside the user’s expected APIG workflow.

Env Variable Harvesting

High
Category
Data Exfiltration
Content
os.environ.get("SKILL_QUALITY_AGENT")
    or os.environ.get("HERMES_AGENT_NAME")
    or os.environ.get("AGENT_NAME")
    or ("hermes" if any(k.startswith("HERMES") for k in os.environ) else "unknown")
)
TRIGGER_TYPE = os.environ.get("SKILL_QUALITY_TRIGGER", "agent")
# 上报来源: report_test(测试数据) / report_user(用户使用,默认)
Confidence
70% confidence
Finding
Code enumerates, copies, or searches environment variables for secrets. Bulk environment access can collect credentials unrelated to the skill's stated purpose.

Description-Behavior Mismatch

High
Confidence
97% confidence
Finding
The file primarily implements IAM token retrieval and outbound quality reporting rather than APIG instance lifecycle or API management operations described in the manifest. This mismatch is dangerous because users and reviewers may grant trust and permissions for APIG administration while the code performs unrelated network reporting with access to execution data.

Context-Inappropriate Capability

High
Confidence
98% confidence
Finding
This code collects and transmits execution inputs, outputs, error messages, and full stack traces, which can contain secrets, resource identifiers, API payloads, and operational context unrelated to APIG instance management. Because the manifest describes infrastructure management functions, this hidden telemetry broadens data exposure and violates least privilege and data minimization expectations.

Lp3

Medium
Category
MCP Least Privilege
Confidence
90% confidence
Finding
The skill declares no explicit tool scope or permission boundaries despite requiring environment access and network-capable CLI operations. In an agent setting, this weakens least-privilege controls and can allow broader-than-necessary access to credentials, remote endpoints, and cloud resources if the runtime grants default capabilities.

Natural-Language Policy Violations

Medium
Confidence
88% confidence
Finding
The module docstring, comments, and user-facing strings are written in Chinese and present the SDK instructions and outputs in that locale only. Under the policy, forcing a specific language without user opt-in or documented regional justification is a natural-language policy violation.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The SDK supports disabling TLS certificate verification via SKILL_QUALITY_INSECURE=1, enabling man-in-the-middle interception of IAM token or telemetry traffic. Because this affects authentication and reporting channels, an attacker on the network path could capture tokens or tamper with transmitted execution metadata.

Natural-Language Policy Violations

Low
Confidence
96% confidence
Finding
This markdown file contains a section title with Chinese text, which imposes a language expectation on readers without any opt-in or explanation. Under the language/locale policy rule, forcing or assuming a specific language without user choice can be a policy violation.

Static analysis

Detected: suspicious.insecure_tls_verification

HTTPS certificate verification is disabled.

Warn
Code
suspicious.insecure_tls_verification
Location
scripts/skill_quality_sdk.py:188