Back to skill

Security audit

hwc-cli-guidance

Security checks for vulnerabilities and agentic risk

Overview

This is a Huawei Cloud CLI documentation skill, but it gives unsafe copy-paste examples for cloud credentials, privileged installation, destructive cloud actions, and shell command execution.

Review this skill carefully before installing or following its examples. Treat Huawei Cloud AK/SK values as sensitive secrets, use least-privileged and preferably temporary credentials, verify downloaded CLI binaries, avoid copying the shell=True Python examples, and test destructive cloud commands only against confirmed non-production resources unless you have explicit change approval.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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
Findings (3)

T09 · Insecure Skill Coding Practices

Error
Location
skill.md:236
Finding

Shell Command Injection Through Unsafe subprocess Usage

Content
View full analysis

Vulnerability Details

File Location: skill.md:236-237, skill.md:277, reference/best-practices.md:48, reference/best-practices.md:110-111, and reference/best-practices.md:158
Vulnerability Type: OS command injection
Risk Level: High

Vulnerable Code

python
cmd = f"hcloud obs upload-object --bucket={bucket} --key={file} --file={local_dir}/{file}"
subprocess.run(cmd, shell=True)

The generic command helper repeats the same unsafe pattern:

python
def safe_command(cmd):
    try:
        result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
        if result.returncode != 0:
            print(f"Error: {result.stderr}")
            return None
        return json.loads(result.stdout)
    except Exception as e:
        print(f"Exception: {e}")
        return None

Technical Analysis

The examples construct command strings using values such as bucket, file, and local_dir, and then execute those strings through a command shell. No quoting, validation, or separation between executable arguments and shell syntax is applied.

A filename or argument containing shell metacharacters can therefore alter the intended command. The generic safe_command helper is also unsafe because it accepts an arbitrary command string and forwards it directly to the shell. Error handling does not make this execution pattern safe.

The duplicated examples in skill.md and reference/best-practices.md increase the likelihood that users will copy this vulnerable pattern into automation with access to production cloud credentials.

Attack Path

  1. An attacker gains the ability to create or influence a filename in a directory processed by batch_upload, or to control another value passed into a command-building helper.
  2. The attacker supplies a value containing shell syntax, such as a command separator followed by an attacker-selected command.
  3. The Python code ...[truncated 1096 chars]
Remediation
View remediation

Remediation Suggestions

  • Remove shell=True and pass each command argument as a separate list element.
  • Validate bucket names, server identifiers, object keys, and other externally influenced values against restrictive allowlists.
  • Use os.path.join or pathlib.Path for local paths rather than string concatenation.
  • Do not expose a generic helper that accepts arbitrary command strings.
  • Enable check=True so command failures are handled consistently.
  • Run automation under a least-privileged local account and a narrowly scoped IAM identity.
  • Add tests using filenames and parameters containing spaces, quotes, semicolons, command substitutions, and newline characters.

A safer implementation is:

python
import os
import subprocess

def upload_object(bucket, local_dir, filename):
    local_path = os.path.join(local_dir, filename)
    return subprocess.run(
        [
            "hcloud",
            "obs",
            "upload-object",
            f"--bucket={bucket}",
            f"--key={filename}",
            f"--file={local_path}",
        ],
        shell=False,
        check=True,
        capture_output=True,
        text=True,
    )

T08 · Insecure Dependencies

Warning
Location
reference/installation-guide.md:41
Finding

Unpinned Dependencies and Unverified Mutable Binary Downloads

Content
View full analysis

Vulnerability Details

File Location: skill.md:35-36, skill.md:42-44, reference/installation-guide.md:25-26, reference/installation-guide.md:41-50, reference/installation-guide.md:80, reference/installation-guide.md:184, reference/best-practices.md:242, reference/best-practices.md:246-249, and reference/best-practices.md:277-280
Vulnerability Type: Software supply-chain exposure
Risk Level: Medium

Vulnerable Code

bash
pip install huaweicloudsdkcore
pip install huaweicloudsdkkoocli
bash
# Download the installation package
curl -LO https://dl.koo.cloud/cli/latest/huaweicloud-cli-linux-amd64.tar.gz

# Extract it
tar -xzvf huaweicloud-cli-linux-amd64.tar.gz

# Move it into the system path
sudo mv huaweicloud-cli-linux-amd64 /usr/local/bin/hcloud

# Make it executable
sudo chmod +x /usr/local/bin/hcloud

The CI guidance repeats the mutable download and privileged installation pattern:

yaml
- uses: actions/checkout@v2

- name: Install KooCLI
  run: |
    curl -LO https://dl.koo.cloud/cli/latest/huaweicloud-cli-linux-amd64.tar.gz
    tar -xzvf huaweicloud-cli-linux-amd64.tar.gz
    sudo mv huaweicloud-cli-linux-amd64 /usr/local/bin/hcloud
    sudo chmod +x /usr/local/bin/hcloud

Technical Analysis

The Python packages are installed without exact version constraints or a lockfile. Consequently, the code installed by the same documented command can change over time without a corresponding review of this project.

The binary installation uses a mutable latest URL and performs no checksum or signature verification before placing the downloaded executable in /usr/local/bin. TLS protects transport under normal conditions but does not establish that the retrieved artifact is the exact version reviewed or approved by the user.

The CI example also references actions/checkout@v2 using a movable version tag rather than an immutable commit digest. ...[truncated 1437 chars]

Remediation
View remediation

Remediation Suggestions

  • Pin Python dependencies to reviewed, exact versions and maintain hashes in a lockfile.
  • Replace the mutable latest URL with a version-specific vendor URL.
  • Obtain the expected SHA-256 digest or signing certificate through an authenticated, vendor-controlled channel.
  • Verify the archive before extraction or execution, and terminate installation if verification fails.
  • Pin third-party CI actions to immutable commit SHAs rather than movable major-version tags.
  • Prefer installation in an isolated virtual environment or dedicated tool directory instead of writing directly to a system-wide path.
  • Run dependency scanning and review new versions before updating pins.
  • Restrict CI network access and permissions so an installation-stage compromise cannot automatically access production credentials.

An integrity-checking installation flow should follow this pattern:

bash
VERSION="reviewed-version"
EXPECTED_SHA256="vendor-published-sha256"

curl --fail --show-error --location \
  --output huaweicloud-cli.tar.gz \
  "https://vendor.example/releases/${VERSION}/huaweicloud-cli-linux-amd64.tar.gz"

printf '%s  %s\n' "$EXPECTED_SHA256" "huaweicloud-cli.tar.gz" | sha256sum --check -
tar -xzvf huaweicloud-cli.tar.gz

The URL, version, and checksum must be replaced with values published by the authoritative vendor.

T09 · Insecure Skill Coding Practices

Warning
Location
reference/best-practices.md:253
Finding

Huawei Cloud Secret Keys Exposed Through Process Command-Line Arguments

Content
View full analysis

Vulnerability Details

File Location: reference/best-practices.md:253 and reference/best-practices.md:288
Vulnerability Type: Sensitive credential exposure
Risk Level: Medium

Vulnerable Code

yaml
- name: Configure KooCLI
  run: |
    hcloud configure init --ak=${{ secrets.HUAWEICLOUD_AK }} --sk=${{ secrets.HUAWEICLOUD_SK }} --region=cn-north-4

The Jenkins example uses the same command-line credential pattern:

groovy
stage('Configure') {
    steps {
        sh '''
            hcloud configure init --ak=${HUAWEICLOUD_AK} --sk=${HUAWEICLOUD_SK} --region=cn-north-4
        '''
    }
}

Technical Analysis

Both CI examples expand the Access Key ID and Secret Access Key directly into command-line arguments. Process arguments may be observable through process inspection, runner diagnostics, command auditing, debugging facilities, crash reports, or shell tracing.

CI masking can reduce accidental log exposure, but it does not eliminate the exposure of a secret placed in a process argument. The risk is greater on shared or insufficiently isolated workers and when third-party tools or diagnostic collectors can inspect running processes.

Attack Path

  1. The CI platform retrieves Huawei Cloud credentials from its secret store.
  2. The shell expands the secret values into the hcloud configure init command line.
  3. The resulting process starts with the AK and SK present in its argument vector.
  4. A co-resident process, compromised build step, diagnostic tool, command logger, or verbose shell configuration captures the process arguments.
  5. The attacker extracts the credentials and uses them outside the CI environment.
  6. The attacker invokes Huawei Cloud APIs within the IAM permissions granted to the exposed identity.

Impact Assessment

Exposure of the Secret Access Key can permit unauthorized authenticated access to Huawei Cloud. The exact scope depends on the ...[truncated 412 chars]

Remediation
View remediation

Remediation Suggestions

  • Prefer short-lived, federated credentials obtained through the CI platform's workload identity mechanism.
  • If supported by KooCLI, supply credentials through its documented environment-variable, protected standard-input, or external credential-provider interface rather than command-line options.
  • Disable shell tracing and avoid printing complete commands containing sensitive values.
  • Use dedicated, ephemeral, isolated CI workers for privileged deployment jobs.
  • Apply least-privilege IAM policies and separate development and production identities.
  • Rotate any credential suspected of having appeared in process arguments, logs, or diagnostic artifacts.
  • Configure secret masking as defense in depth, while recognizing that masking does not secure the process argument vector.
  • Ensure generated credential files have restrictive permissions and are securely removed after ephemeral jobs complete.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (26)

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
97% confidence
Finding

The Python helper executes arbitrary command strings with shell=True, which allows shell metacharacters and injected parameters to be interpreted by the shell. If any part of cmd is influenced by user input or upstream data, an attacker could execute unintended system commands with the privileges of the process.

Content

Scanner excerpt · reference/best-practices.md (reported line 48)May include surrounding context.

md
def safe_command(cmd):
    try:
        result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
        if result.returncode != 0:
            print(f"Error: {result.stderr}")
            return None

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
99% confidence
Finding

The batch upload example builds a shell command using bucket, file, and local_dir values and then runs it with shell=True. Because filenames and paths may contain shell metacharacters or attacker-controlled content, this can lead to command injection and arbitrary command execution during uploads.

Content

Scanner excerpt · reference/best-practices.md (reported line 111)May include surrounding context.

batch = files[i:i+BATCH_SIZE] for file in batch: cmd = f"hcloud obs upload-object --bucket={bucket} --key={file} --file={local_dir}/{file}" subprocess.run(cmd, shell=True) print(f"Uploaded batch {i//BATCH_SIZE + 1}")

text

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
96% confidence
Finding

The retry helper again executes arbitrary command strings with shell=True, preserving the same command-injection risk while wrapping it in retry logic. In an automation context managing cloud infrastructure, successful injection could lead to host compromise, credential theft, or unauthorized cloud actions.

Content

Scanner excerpt · reference/best-practices.md (reported line 158)May include surrounding context.

md
def request_with_retry(cmd, max_retries=3):
    for attempt in range(max_retries):
        result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
        
        if result.returncode != 429:
            return result

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
85% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · reference/installation-guide.md (reported line 169)May include surrounding context.

bash
# Linux/macOS
sudo rm /usr/local/bin/hcloud

# Windows
Remove-Item -Path "huaweicloud-cli-windows-amd64" -Recurse -Force

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
98% confidence
Finding

The Python example constructs a shell command using unsanitized values derived from bucket, local_dir, and especially filenames from os.listdir(), then executes it with shell=True. If a filename or parameter contains shell metacharacters, an attacker could trigger arbitrary command execution on the machine running the script.

Content

Scanner excerpt · skill.md (reported line 237)May include surrounding context.

batch = files[i:i+BATCH_SIZE] for file in batch: cmd = f"hcloud obs upload-object --bucket={bucket} --key={file} --file={local_dir}/{file}" subprocess.run(cmd, shell=True) print(f"Uploaded batch {i//BATCH_SIZE + 1}")

text

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
95% confidence
Finding

The helper function executes any provided string command with shell=True, which makes it a generic command-injection sink if untrusted input reaches cmd. Because the function is framed as a 'safe' practice, it may encourage unsafe reuse and increase the likelihood of downstream exploitation.

Content

Scanner excerpt · skill.md (reported line 277)May include surrounding context.

md
def safe_command(cmd):
    try:
        result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
        if result.returncode != 0:
            print(f"Error: {result.stderr}")
            return None

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

This markdown file includes a '批量启动云服务器' example that starts multiple cloud servers, which can affect cost, availability, and system state. The surrounding documentation does not provide any warning, confirmation note, or cautionary disclosure about operating on production resources.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The markdown includes an example that iterates through a local directory and uploads files to an OBS bucket. Because this transfers potentially sensitive local data to a remote service, the skill description should explicitly warn users to validate file contents, destination bucket, and access permissions before use.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The GitHub Actions and Jenkins examples configure cloud credentials and then start a server during deployment. The markdown does not warn that these automated workflows can change production infrastructure and should be limited to approved environments and protected secrets.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The documentation includes operationally destructive commands such as stopping and rebooting cloud servers without any warning about service disruption, production impact, or the need for explicit confirmation before use. In a command-reference skill, users may copy commands directly, so omission of safety guidance increases the risk of accidental downtime or misuse in sensitive environments.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The delete-object command is presented without warning that it is destructive and may permanently remove data, potentially causing data loss if users run it against the wrong bucket or key. Because this is a terse command reference, users are especially likely to execute examples as-is, making the lack of irreversible-action warning materially risky.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The guide instructs users to create long-lived access keys and enter them into the CLI, but it provides no guidance on secure storage, least privilege, rotation, or avoiding exposure in files and shell history. This increases the risk of credential leakage and subsequent unauthorized access to the user's cloud account.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The instructions tell users to move a downloaded binary into a system path and change permissions with sudo, but do not warn that these are privileged operations affecting system-wide executables. If the downloaded artifact is tampered with or the user misunderstands the commands, this could install unsafe software with elevated trust.

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · reference/best-practices.md (reported line 248)May include surrounding context.

md
tar -xzvf huaweicloud-cli-linux-amd64.tar.gz

# 移动到系统路径
sudo mv huaweicloud-cli-linux-amd64 /usr/local/bin/hcloud

# 添加执行权限
sudo chmod +x /usr/local/bin/hcloud

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · reference/best-practices.md (reported line 249)May include surrounding context.

md
tar -xzvf huaweicloud-cli-linux-amd64.tar.gz

# 移动到系统路径
sudo mv huaweicloud-cli-linux-amd64 /usr/local/bin/hcloud

# 添加执行权限
sudo chmod +x /usr/local/bin/hcloud

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · reference/best-practices.md (reported line 279)May include surrounding context.

md
tar -xzvf huaweicloud-cli-linux-amd64.tar.gz

# 移动到系统路径
sudo mv huaweicloud-cli-linux-amd64 /usr/local/bin/hcloud

# 添加执行权限
sudo chmod +x /usr/local/bin/hcloud

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · reference/best-practices.md (reported line 280)May include surrounding context.

md
tar -xzvf huaweicloud-cli-linux-amd64.tar.gz

# 移动到系统路径
sudo mv huaweicloud-cli-linux-amd64 /usr/local/bin/hcloud

# 添加执行权限
sudo chmod +x /usr/local/bin/hcloud

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · reference/installation-guide.md (reported line 47)May include surrounding context.

md
tar -xzvf huaweicloud-cli-linux-amd64.tar.gz

# 移动到系统路径
sudo mv huaweicloud-cli-linux-amd64 /usr/local/bin/hcloud

# 添加执行权限
sudo chmod +x /usr/local/bin/hcloud

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · reference/installation-guide.md (reported line 50)May include surrounding context.

md
tar -xzvf huaweicloud-cli-linux-amd64.tar.gz

# 移动到系统路径
sudo mv huaweicloud-cli-linux-amd64 /usr/local/bin/hcloud

# 添加执行权限
sudo chmod +x /usr/local/bin/hcloud

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill instructs users to create and enter Access Key ID and Secret Access Key but does not warn that these are sensitive secrets that must not be pasted into logs, chats, code, or shared terminals. In an agent-skill context, omission of credential-handling guidance can directly lead to secret exposure and unauthorized cloud access.

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · reference/installation-guide.md (reported line 169)May include surrounding context.

bash
curl -LO https://dl.koo.cloud/cli/latest/huaweicloud-cli-linux-amd64.tar.gz
tar -xzvf huaweicloud-cli-linux-amd64.tar.gz
sudo mv huaweicloud-cli-linux-amd64 /usr/local/bin/hcloud

方法三:使用 PowerShell 安装(Windows)

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · skill.md (reported line 44)May include surrounding context.

bash
curl -LO https://dl.koo.cloud/cli/latest/huaweicloud-cli-linux-amd64.tar.gz
tar -xzvf huaweicloud-cli-linux-amd64.tar.gz
sudo mv huaweicloud-cli-linux-amd64 /usr/local/bin/hcloud

方法三:使用 PowerShell 安装(Windows)

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The guide includes operational commands that can modify or delete cloud resources, such as stopping or rebooting servers and deleting objects, without any warning about production impact, confirmation steps, or least-privilege usage. In a skill intended to guide real cloud operations, this omission increases the chance of accidental destructive actions by users or downstream agents.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
80% confidence
Finding

The function invocation example omits a warning that the event payload may send user, application, or system data to a remote cloud function for processing. This can lead to unintended disclosure of sensitive data if users pass production events or secrets without understanding where the payload goes.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
83% confidence
Finding

The guide includes authentication configuration and profile-listing commands without noting that account or region details may be exposed on shared terminals, recordings, or CI logs. While the shown example does not print the secret itself, it normalizes handling authentication-related commands without operational security guidance.

Content

No source excerpt is available for this finding.