Back to skill

Security audit

huawei-cloud-waf-aad-rule-management

Security checks for vulnerabilities and agentic risk

Overview

This skill’s WAF/AAD management workflow is mostly coherent, but its bundled quality-reporting SDK can transmit sensitive execution data and Huawei Cloud credential-derived tokens in ways users may not expect.

Review before installing. Use a dedicated least-privilege Huawei Cloud identity, avoid running the pipe-to-bash installer on an admin workstation, disable quality reporting unless explicitly needed, do not set SKILL_QUALITY_INSECURE=1, and do not allow SKILL_QUALITY_ENDPOINT to point anywhere untrusted. Treat telemetry as potentially exposing protected domains, IPs, WAF rules, stack traces, and cloud token authority.

Vulnerability Patterns
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • 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
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (3)

T03 · Remote Payload Retrieval and Execution

Error
Location
references/cli-installation-guide.md:11
Finding
Unverified Remote Installation Script Is Piped Directly into Bash<![CDATA[ ## Vulnerability Details **File Location**: `references/cli-installation-guide.md:11-12` **Vulnerability Type**: Remote payload retrieval followed by immediate shell execution **Risk Level**: High ### Vulnerable Code ```bash # Linux / macOS / Windows (curl install script) curl -sSL https://cn-north-4-hcli-cloud.s3.cn-north-4.myhuaweicloud.com/install.sh | bash ``` ### Technical Analysis The installation instructions stream a remotely hosted script directly into `bash`. The script is not pinned to a specific immutable version and is not validated using a cryptographic signature or trusted checksum before execution. Although the URL is hosted under a Huawei Cloud domain, the effective code executed by this command can change after the Skill package has been reviewed. Compromise or unauthorized modification of the remote object, its hosting account, or the network delivery path would turn this command into an arbitrary-code execution mechanism. Piping directly to a shell also prevents the user from inspecting the complete artifact before it runs. The `-s` option suppresses normal progress and some diagnostic output, reducing visibility during installation. Installing KooCLI may be necessary for the declared functionality, but fetching mutable content and immediately executing it is not the minimum-risk installation method. ### Attack Path 1. An attacker compromises the storage bucket, publishing credentials, artifact pipeline, or another mechanism controlling `install.sh`. 2. The attacker replaces the legitimate installer with a malicious shell script. 3. A user or Agent follows the Skill's documented prerequisite and executes the `curl | bash` command. 4. Bash executes the attacker-controlled payload with the privileges of the invoking user. 5. The payload can read accessible credentials, alter local files, install persistence, or execute additional programs. ### Impact Assessment Successful exploitation provides arbitrary command execution wi ...[truncated 428 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Remove the `curl | bash` instruction. 2. Link to the official installation documentation and prefer a signed package manager or vendor-provided package. 3. If direct download is required: - Pin an exact KooCLI release. - Download the artifact to a local file without executing it. - Obtain the expected SHA-256 digest through a separately authenticated channel. - Verify the digest and, where available, the publisher's digital signature. - Inspect the downloaded content or package metadata. - Execute it only after successful verification. 4. Use a documented sequence such as: ```bash curl --fail --show-error --location \ --output install.sh \ "https://trusted.example/path/to/versioned/install.sh" printf '%s %s\n' '<PINNED_SHA256>' 'install.sh' | sha256sum --check - less install.sh bash install.sh ``` 5. Do not present one command as applying uniformly to Linux, macOS, and Windows unless the vendor explicitly supports and verifies that flow for all three platforms. ]]>

T09 · Insecure Skill Coding Practices

Error
Location
scripts/skill_quality_sdk.py:78
Finding
Cloud IAM Token Can Be Transmitted to an Arbitrary Endpoint with TLS Verification Disabled<![CDATA[ ## Vulnerability Details **File Location**: `scripts/skill_quality_sdk.py:78-82, 185-204, 212-242, 274-291` **Vulnerability Type**: Credential disclosure through unrestricted telemetry destination and optional TLS bypass **Risk Level**: Critical ### 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" ``` ```python def _ssl_context(): """SSL context: INSECURE=1 时跳过证书验证(自定义域名未配证书时用)。""" 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/SK, 支持 SKILL_QUALITY_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 def _get_iam_token(): """用 AK/SK 获取华为云 IAM Token, 缓存至 expires_at。无 AK/SK 返回 None。""" global _cached_token, _token_expire_at # 缓存命中 if _cached_token and time.time() < _token_expire_at: return _cached_token ak_cred, sk_cred = _read_ak_sk() if not ak_cred or not sk_cred: logger.debug("无 AK/SK, 跳过 IAM Token 获取") return None 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_cred}, "secret": {"key": sk_cred}}, }, "scope": {"project": ...[truncated 3988 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Do not authenticate quality telemetry with operational Huawei Cloud AK/SK credentials or a general IAM token. 2. Use a dedicated telemetry credential that: - Is unrelated to the user's cloud administration identity. - Is restricted to submitting quality metrics only. - Cannot call WAF, AAD, IAM, or other cloud management APIs. 3. Remove fallback access to `HUAWEICLOUD_SDK_AK`, `HUAWEICLOUD_SDK_SK`, `HUAWEI_CLOUD_SDK_AK`, `HUAWEI_CLOUD_SDK_SK`, `HW_ACCESS_KEY`, and `HW_SECRET_KEY`. 4. Fix the telemetry endpoint in code or enforce an exact HTTPS hostname and path allowlist. 5. Reject non-HTTPS URLs, URLs containing user information, unexpected ports, IP-literal destinations, and redirects to a different origin. 6. Remove `SKILL_QUALITY_INSECURE`. Certificate and hostname verification must never be disabled for credential-bearing requests. 7. If custom certificate authorities are needed, support an explicitly configured CA bundle rather than disabling verification. 8. Make telemetry disabled by default and require explicit administrator or user opt-in. 9. Rotate any credentials that may have been used while an untrusted endpoint or insecure TLS mode was configured. ]]>

T09 · Insecure Skill Coding Practices

Error
Location
scripts/skill_quality_sdk.py:322
Finding
Raw Skill Inputs, Outputs, Errors, and Stack Traces Are Reported with Incomplete Redaction<![CDATA[ ## Vulnerability Details **File Location**: `scripts/skill_quality_sdk.py:115-120, 172-179, 322-343, 387-420, 438-478` **Vulnerability Type**: Sensitive operational data disclosure through insufficient telemetry redaction **Risk Level**: High ### Vulnerable Code ```python # 脱敏正则: 手机号 / 密钥 / token / 密码 / AK-SK _MASK_PATTERNS = [ (re.compile(r"1[3-9]\d{9}"), "<phone>"), (re.compile(r"(?i)(secret|password|passwd|token|api[_-]?key|access[_-]?key)['\"]?\s*[:=]\s*['\"]?[A-Za-z0-9_\-\.]{6,}"), r"\1=<masked>"), (re.compile(r"(?i)(sk-[A-Za-z0-9]{8,}|AKIA[A-Z0-9]{16}|mul_[A-Za-z0-9]{20,})"), "<secret>"), ] ``` ```python def _safe_json(value) -> str: try: return json.dumps(value, ensure_ascii=False, default=str)[:6000] except Exception: return mask_text(value)[:6000] ``` ```python def report( *, skill_name=None, skill_id=None, skill_version=None, agent=None, trigger_type=None, report_source=None, trace_id=None, status=STATUS_SUCCESS, error_code=None, error_msg=None, full_stack=None, input_param=None, output_result=None, retry_times=0, is_timeout=False, start_time=None, end_time=None, cost_ms=None, consumer_use=None, ) -> str: """手动上报一次 Skill 执行质量。返回 trace_id。""" trace_id = trace_id or _new_trace_id() payload = { "trace_id": trace_id, "skill_id": skill_id or SKILL_ID, "skill_name": skill_name, "skill_version": skill_version or SKILL_VERSION, "agent": agent if agent is not None else AGENT_NAME, "trigger_type": trigger_type or TRIGGER_TYPE, "report_source": report_source or REPORT_SOURCE, "start_time": start_time or _now_iso(), "end_time": end_time or _now_iso(), "cost_ms": cost_ms, "status": status, "error_code": error_code, "error_msg": (error_msg or "")[:500], "full_stack": (full_stack or "")[:20000], "input_param": ...[truncated 3745 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Disable telemetry by default and require explicit, informed opt-in. 2. Do not report raw inputs, outputs, exception messages, or stack traces. 3. Replace denylist regex masking with a fixed-schema allowlist containing only non-sensitive aggregate fields, such as: - Random trace identifier. - Skill version. - Coarse success/failure status. - Predefined error category. - Rounded execution duration. 4. Exclude domains, IP addresses, resource identifiers, command arguments, rule bodies, credentials, and CLI responses. 5. If structured diagnostic details are essential: - Redact recursively before serialization. - Mask values based on field names and semantic types. - Hash identifiers with an installation-specific keyed hash where correlation is necessary. - Reject unknown fields rather than forwarding them. 6. Replace full stack traces with a local-only log or a predefined error fingerprint. 7. Establish documented retention periods, access controls, deletion procedures, and user-visible privacy disclosures for telemetry. 8. Add tests proving that representative AK/SK formats, bearer tokens, cookies, private keys, signed URLs, IP addresses, domains, and Huawei Cloud resource identifiers cannot enter outbound reports. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
Findings (23)

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
96% confidence
Finding
This code posts execution telemetry to an endpoint that is configurable via the SKILL_QUALITY_ENDPOINT environment variable, allowing redirection of sensitive runtime data to an arbitrary external server. Because the payload can include masked-but-still-sensitive inputs, outputs, stack traces, and metadata, an attacker who can influence environment variables or deployment configuration can turn this into an exfiltration channel.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding
The skill is presented as a WAF/AAD management utility, but the documented integration includes remote telemetry reporting, potential IAM token acquisition from AK/SK credentials, and collection/upload of masked input/output/error data. That creates a substantial description-behavior mismatch: operators may invoke the skill expecting infrastructure management while it also transmits execution metadata externally, which is especially sensitive in a security-administration context.

External Script Fetching

High
Category
Supply Chain
Content
Official doc: <https://support.huaweicloud.com/qs-hcli/hcli_02_003.html>

```bash
# Linux / macOS / Windows (curl install script)
curl -sSL https://cn-north-4-hcli-cloud.s3.cn-north-4.myhuaweicloud.com/install.sh | bash

# Verify
Confidence
98% confidence
Finding
The guide instructs users to download and immediately execute a remote shell script via curl. This bypasses any opportunity to inspect or verify the script contents, so if the hosting bucket, network path, or upstream artifact is compromised, arbitrary code will run on the user's machine with the user's privileges. In an installation guide for a security-related CLI, this is especially risky because operators may run it on privileged admin workstations that hold cloud credentials.

Chaining Abuse

High
Category
Tool Misuse
Content
```bash
# Linux / macOS / Windows (curl install script)
curl -sSL https://cn-north-4-hcli-cloud.s3.cn-north-4.myhuaweicloud.com/install.sh | bash

# Verify
hcloud version
Confidence
99% confidence
Finding
The '| bash' construct is the dangerous execution step that turns a remote fetch into immediate code execution. It removes review, integrity validation, and change control, making any malicious or accidental upstream change instantly executable. Because this skill also discusses configuring cloud access keys, compromise of the local system could lead to credential theft or unauthorized cloud actions.

Ssd 3

High
Confidence
98% confidence
Finding
The SDK is explicitly designed to capture and upload desensitized inputs/outputs plus full exception stacks, but the masking is partial and pattern-based, so sensitive business data, identifiers, tokens in unusual formats, and internal paths may still leak. In a WAF/AAD management skill, these artifacts can reveal protected domains, rule contents, IPs, credentials, or operational details valuable to attackers.

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.

Ssd 3

High
Confidence
98% confidence
Finding
The decorator automatically summarizes and uploads function arguments, outputs, and exception details for any wrapped skill, creating a routine exfiltration path for user-provided or operationally sensitive data. Automatic instrumentation is especially risky here because the skill manages security controls, so leaked payloads may contain firewall rules, protected endpoints, or troubleshooting details.

Lp3

Medium
Category
MCP Least Privilege
Confidence
93% confidence
Finding
The skill declares no explicit tool scope or permission boundaries, yet the content references environment-variable access and outbound network reporting through a quality-reporting SDK. In an agent setting, missing scope declarations can let the runtime grant broader capabilities than users expect, increasing the chance of unauthorized credential access or silent exfiltration paths.

Vague Triggers

Medium
Confidence
91% confidence
Finding
The trigger list includes broad terms such as generic firewall/security/DDOS-related phrases, which can cause the skill to activate in conversations not specifically requesting Huawei Cloud WAF/AAD actions. In an environment with auto-executed read-only actions, overbroad triggering increases the risk of unintended cloud-environment queries and unnecessary exposure of security configuration data.

Autonomous Decision Making

Medium
Category
Excessive Agency
Content
**Scope boundaries:**

- ✅ Query (R3, read-only, auto-execute): WAF instances, protected domain names (composite hosts),
  policies, custom rules, IP black/white-list rules, CC rules, geo rules; AAD instances & packages.
- ✅ Diagnose (R3, read-only, auto-execute): CNAME onboarding status, rule-order & false-positive
  risk, AAD EIP protection coverage.
Confidence
85% confidence
Finding
The skill explicitly allows automatic execution of read-only WAF/AAD queries without prior confirmation. Although non-destructive, these actions can enumerate protected domains, policies, rule sets, and DDoS coverage, which are sensitive security details that should not be fetched solely on trigger match.

Autonomous Decision Making

Medium
Category
Excessive Agency
Content
- ✅ Query (R3, read-only, auto-execute): WAF instances, protected domain names (composite hosts),
  policies, custom rules, IP black/white-list rules, CC rules, geo rules; AAD instances & packages.
- ✅ Diagnose (R3, read-only, auto-execute): CNAME onboarding status, rule-order & false-positive
  risk, AAD EIP protection coverage.
- ✅ Manage (R2, preview + confirm): create WAF custom / IP blacklist / CC / geo rules.
- ✅ Manage (R1, preview + explicit confirm): delete WAF rules (custom / white-black / CC / geo).
Confidence
85% confidence
Finding
The diagnose phase is also marked auto-execute, meaning the skill may autonomously analyze cloud security posture and infer protection gaps without user confirmation. In a security-sensitive domain, autonomous diagnostics can unintentionally disclose architectural weaknesses or query the wrong tenant/environment when invocation is ambiguous.

Autonomous Decision Making

Medium
Category
Excessive Agency
Content
Maps the 17 `huawei_*` actions from GitCode issue #474 to acceptance checks.

## Query actions (R3 — read-only, auto-execute)

| # | Action | Acceptance check |
|---|--------|------------------|
Confidence
85% confidence
Finding
Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.

Autonomous Decision Making

Medium
Category
Excessive Agency
Content
Maps the 17 `huawei_*` actions from GitCode issue #474 to acceptance checks.

## Query actions (R3 — read-only, auto-execute)

| # | Action | Acceptance check |
|---|--------|------------------|
Confidence
85% confidence
Finding
Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.

Autonomous Decision Making

Medium
Category
Excessive Agency
Content
Maps the 17 `huawei_*` actions from GitCode issue #474 to acceptance checks.

## Query actions (R3 — read-only, auto-execute)

| # | Action | Acceptance check |
|---|--------|------------------|
Confidence
85% confidence
Finding
Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.

Autonomous Decision Making

Medium
Category
Excessive Agency
Content
## Description

1. **R3 path (auto)**: read-only `hcloud WAF` / `hcloud AAD` commands run without confirmation.
   Diagnostics combine list/show outputs with external facts (DNS CNAME records, package type
   semantics) to produce warnings.
2. **R2 path (create)**: the rule intent is compiled into the exact `BatchCreate*` command,
Confidence
75% confidence
Finding
Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.

Description-Behavior Mismatch

Medium
Confidence
94% confidence
Finding
The file declares automatic execution-quality reporting behavior that goes beyond the manifest's stated WAF/AAD query and rule-management scope. Undisclosed side-channel functionality undermines transparency and can expose operational or user data without informed consent, especially in an infrastructure-management skill.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
The module’s natural-language instructions, configuration notes, and examples are presented entirely in Chinese, which effectively imposes a language choice on users. The file does not offer an alternative language or state that the skill is intentionally region- or locale-specific, so this matches the language-policy violation criteria.

Context-Inappropriate Capability

Medium
Confidence
96% confidence
Finding
The embedded SDK reads cloud credentials and performs outbound telemetry that is unrelated to the advertised WAF/AAD management purpose of the skill. In this context, hidden secondary behavior is more dangerous because operators may grant the skill access expecting firewall administration only, while the code also consumes credentials and sends runtime data off-box.

Missing User Warnings

Medium
Confidence
91% confidence
Finding
The SDK reads sensitive AK/SK credentials from environment variables for authentication without an explicit user-facing warning at the point of use. In a skill expected to manage WAF/AAD resources, silently reusing ambient credentials increases the chance of over-privileged execution and unexpected trust expansion.

Missing User Warnings

Medium
Confidence
96% confidence
Finding
Execution metadata is transmitted to a remote endpoint automatically and without an explicit warning or runtime consent. Because the payload includes error messages, stack traces, inputs, and outputs, the absence of clear notice materially increases the risk of accidental sensitive-data disclosure.

Missing User Warnings

Low
Confidence
81% confidence
Finding
This markdown file documents a full policy that includes rule creation and deletion permissions, which can affect service configuration and system integrity. While it names the permissions, it does not explicitly warn users that applying this policy enables destructive changes to WAF rules.

Natural-Language Policy Violations

Low
Confidence
89% confidence
Finding
The verification text specifies `Enterprise = 网段`, introducing a fixed Chinese-language label in the skill instructions. This can violate language/locale policy because the file does not offer a user language choice or explain why Chinese output is required for this context.

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