Back to skill

Security audit

huawei-cloud-rds-failover

Security checks for vulnerabilities and agentic risk

Overview

The skill is a disclosed Huawei Cloud RDS failover tool, but it needs review because one path can run a real failover against an instance the user did not explicitly configure.

Review before installing or running. Use a least-privilege hcloud profile scoped to the intended RDS instance, fix config/config.json to the exact target, and inspect experiment.json and risk_assessment.json before any --yes run. Do not use --force or run the live execute phase outside an approved test or maintenance window.

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

T09 · Insecure Skill Coding Practices

Error
Location
scripts/prepare.py:443
Finding

Automatic Target Substitution Can Trigger Failover on an Unapproved RDS Instance

Content
View full analysis

Vulnerability Details

File Locations:

  • scripts/prepare.py:443-455
  • scripts/execute.py:280-283
  • scripts/execute.py:165-169
  • scripts/execute.py:441-442

Vulnerability Type: Improper authorization of a destructive operation target
Risk Level: High

Complete Code Snippets

scripts/prepare.py:443-455:

python
# 选择目标实例 — 优先使用 config.json 中的 instance_id
target = next((i for i in ha_instances if i["id"] == instance_id), None)
if not target:
    if len(ha_instances) == 1:
        target = ha_instances[0]
        instance_id = target["id"]  # 同步更新,后续 experiment.json 和 execute 均使用新值
        print(f"  config.json 中的 instance_id 未匹配,区域仅有 1 个 HA 实例:")
        print(f"    名称: {target['name']}")
        print(f"    ID: {instance_id}")
        print(f"    引擎: {target['engine']}  状态: {target['status']}")
        print(f"  ⚠ 此实例未经 config.json 显式指定,请确认无误。")

scripts/execute.py:280-283:

python
exp_instance_id = experiment.get("target", {}).get("instance_id")
if exp_instance_id and exp_instance_id != instance_id:
    instance_id = exp_instance_id
    print(f"[配置] instance_id 已从 experiment.json 覆盖为 {instance_id}")

scripts/execute.py:165-169:

python
def execute_failover(region, instance_id):
    """调用 StartFailover API"""
    resp = run_hcloud("RDS", "StartFailover", region, [f"--instance_id={instance_id}"])
    if resp.get("_error"):
        return None, resp.get("stderr")

scripts/execute.py:441-442:

python
print(f"\n[执行] 调用 StartFailover...")
failover_resp, failover_err = execute_failover(region, instance_id)

Technical Analysis

The user identifies the authorized failover target through config/config.json. During preparation, however, if that configured instance ID does not match any enumerated HA instance and the region contains exactly one HA instance, the code silently changes the effective target to that instance.

Although the preparation script prints a warning asking the user to confirm the replacem ...[truncated 3079 chars]

Remediation
View remediation

Remediation Suggestions

  1. Fail closed on target mismatch
    If the configured instance_id does not match an enumerated HA instance, terminate preparation with an error. Do not automatically select the sole instance in the region.

  2. Require explicit target authorization
    If fallback selection is retained, require a dedicated option containing the exact replacement identifier, such as:

    bash
    --confirm-target <instance-id>
    

    The supplied value must exactly match the selected instance before writing executable artifacts.

  3. Enforce configuration consistency during execution
    Reject execution when config.json, experiment.json, and risk_assessment.json do not contain identical region and instance identifiers. Do not treat generated artifacts as automatically authoritative over the user-controlled configuration.

  4. Bind confirmation to the target
    Replace the generic --yes authorization with target-specific confirmation for destructive operations, or require both --yes and an exact target assertion.

  5. Protect generated artifacts
    Record the authorized region and instance ID in a manifest and verify its integrity before execution. At minimum, validate ownership and reject unexpected target changes between preparation and execution.

  6. Display the final target immediately before execution
    Present the final instance name, ID, region, and engine immediately before StartFailover. For interactive use, require an exact typed confirmation; for automation, require an equivalent non-interactive target-binding parameter.

  7. Add regression tests
    Tests should verify that:

    • An unmatched configured ID always fails closed.
    • A sole regional HA instance is never selected implicitly.
    • Any mismatch among configuration and generated artifacts blocks StartFailover.
    • Generic --yes cannot authorize a changed target.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (16)

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
91% confidence
Finding

The skill documents shell execution, file reads, and file writes, but it does not declare any tool scope or permission boundaries. For a workflow that can perform a real RDS failover and generate artifacts, missing explicit capability restrictions increases the chance of over-broad agent execution, unintended command use, or unsafe invocation against production resources.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

Using broad trigger phrases such as "failover" and "高可用验证" can cause the skill to activate during general discussion, troubleshooting, or educational queries rather than an explicit request to operate on Huawei Cloud RDS. In this skill's context, mistaken activation is risky because the documented workflow includes a real state-changing switchover operation.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The activation conditions are written broadly enough to match users who merely "need" failover validation or DR verification, without distinguishing between asking for guidance and asking to run a destructive workflow. Because this skill can reach an execute phase that triggers actual failover, ambiguous activation materially raises the risk of accidental production-impacting actions.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The document provides a real failover execution command (python3 scripts/execute.py --config-dir experiments --yes) that triggers a production-impacting operation, but it does not present a prominent warning about service interruption, environment scoping, rollback prerequisites, or approval requirements immediately adjacent to the command. In an operational runbook for HA databases, this omission can lead users to execute a disruptive action during routine verification, causing avoidable downtime or unintended topology changes.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The end-to-end validation script includes a live failover step as part of a seemingly standard verification flow, which increases the chance that a user will run the entire sequence without appreciating that one step changes service state. Because this is framed as validation rather than a hazardous operation, it can normalize execution of a disruptive database switchover and lead to accidental outages in live environments.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

This code file contains natural-language documentation entirely in Chinese and later emits Chinese-only user-visible ValueError messages. Under the policy, forcing a specific language without user opt-in or a documented locale-specific justification is a violation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

This code presents all user-facing docstrings and error messages in Chinese, including installation guidance and configuration errors. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation unless the locale restriction is explicitly justified, which is not present in this file.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/config.py (reported line 71)May include surrounding context.

python
if extra_args:
        cmd.extend(extra_args)
    try:
        result = subprocess.run(cmd, capture_output=True, text=True, timeout=120)
    except subprocess.TimeoutExpired:
        return {"_error": True, "stderr": "hcloud 命令超时(120s),请检查网络或减少查询范围"}
    except FileNotFoundError:

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This code file contains natural-language instructions, descriptions, and runtime messages only in Chinese, including the module docstring and CLI help text. Under the policy, forcing a specific language without opt-in is a natural-language policy violation unless the locale restriction is explicitly justified, which is not present here.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/run.py (reported line 58)May include surrounding context.

python
elif phase == "report":
        cmd.extend(["--config-dir", config_dir])

    result = subprocess.run(cmd, cwd=SCRIPT_DIR)
    return result.returncode == 0

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
86% confidence
Finding

Natural-language policy review applies to all file types. A skill that effectively forces one language for instructions and operation can violate language-choice policy unless it offers opt-in, alternatives, or a clearly justified region-specific constraint.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
89% confidence
Finding

The document forces a specific language/locale for all operational instructions by providing the skill content solely in Chinese. Under the stated policy, language constraints should either offer user choice or be clearly justified as region- or audience-specific.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
89% confidence
Finding

This code calls Huawei Cloud APIs to enumerate RDS instances and IAM policies, then writes experiment, IAM, monitoring, risk, and readiness-report files to disk. Although there are progress prints, the script does not clearly disclose that account/resource metadata will be collected from the cloud environment and persisted into local report files containing instance and policy details.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
96% confidence
Finding

Natural-language policy requires avoiding forced language or locale selection unless the skill offers opt-in or clearly documents a justified regional constraint. Here the report template explicitly fixes the document language to Simplified Chinese, and the script otherwise provides no language selection or explanation that the report must be Chinese-only.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
96% confidence
Finding

The generated HTML explicitly sets lang="zh-CN" and all user-facing report text is fixed in Chinese. This imposes a specific language/locale on output without any opt-in or configurable language selection, which matches the locale-policy concern for natural-language behavior.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
96% confidence
Finding

The module docstring, usage examples, help text, and runtime output are all written exclusively in Chinese, which imposes a language choice on users. Under the policy, locale or language constraints should either be optional, user-selectable, or clearly justified as region-specific; this file does not provide such opt-in or justification.

Content

No source excerpt is available for this finding.