Back to skill

Security audit

huawei-cloud-flexus-l-deploy-jiuwenswarm

Security checks for vulnerabilities and agentic risk

Overview

This appears to be a real Huawei Cloud deployment skill, but it handles secrets and remote root changes in ways that need careful review before installation.

Install only if you are comfortable granting Huawei Cloud credentials that can create resources and run root COC commands. Use temporary least-privilege credentials, review costs and target instance IDs before running, avoid using it with an encrypted hcloud profile unless you accept the downgrade, do not share COC logs or generated config output, and rotate any model or messaging credentials that may have been printed or stored with broad permissions.

Vulnerability Patterns
  • 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
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
Findings (4)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/config_channel.py:268
Finding
Message channel credentials are stored with overly broad file permissions## Vulnerability Details **File Location**: `scripts/config_channel.py`, lines 268–290 **Vulnerability Type**: Plaintext credential exposure through insecure permissions **Risk Level**: High Equivalent vulnerable logic appears in the Feishu configuration path at lines 384–405 and the DingTalk configuration path at lines 499–521. ### Vulnerable Code ```python # Update Xiaoyi configuration xiaoyi_config['ak'] = '{ak}' xiaoyi_config['sk'] = '{sk}' xiaoyi_config['agent_id'] = '{agent_id}' xiaoyi_config['enabled'] = True # Write updated configuration with open(config_file, 'w', encoding='utf-8') as f: yaml.dump( config, f, default_flow_style=False, allow_unicode=True, sort_keys=False ) print("[OK] Xiaoyi configuration updated - only specific fields modified") PYEOF chmod 644 "$CONFIG_FILE" echo "[OK] Configuration file permissions set" ``` The equivalent Feishu and DingTalk generators store `app_secret` and `client_secret` in the same file and then apply mode `0644`. ### Technical Analysis The generated remote script writes messaging-platform credentials in plaintext to: ```text /root/.jiuwenswarm/config/config.yaml ``` It then explicitly changes that file to mode `0644`. This grants read permission to users outside the owner and group. Although the file is normally located beneath `/root`, relying only on parent-directory traversal restrictions is fragile: alternate permissions, privileged helper processes, container mounts, backups, support tooling, or accidental relocation can expose the file. The file itself does not enforce least privilege. The behavior is inconsistent with the initial deployment template, which applies mode `0600` to the same configuration file. Subsequent channel configuration therefore weakens the protection of existing and newly written secrets. Timestamped backups may also retain insecure permissions after the source file has previously been changed to `0644`. ### Attack Path ...[truncated 964 chars]
Remediation
## Remediation Suggestions 1. Preserve root-only permissions: ```bash install -d -m 700 /root/.jiuwenswarm/config chmod 600 "$CONFIG_FILE" chown root:root "$CONFIG_FILE" ``` 2. Set a restrictive umask before creating configuration files or backups: ```bash umask 077 ``` 3. Create backups with explicit restrictive permissions and verify existing backups: ```bash cp --preserve=mode,ownership "$CONFIG_FILE" "$BACKUP_FILE" chmod 600 "$BACKUP_FILE" chown root:root "$BACKUP_FILE" ``` 4. Prefer a dedicated secret manager or root-only environment file instead of placing secrets in a general YAML configuration file. 5. Add an automated post-write check that rejects files readable by group or others. 6. Rotate any credentials that may already have been written under mode `0644`.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/config_model.py:218
Finding
Model API key is emitted into remotely retained COC execution output## Vulnerability Details **File Location**: `scripts/config_model.py`, lines 218–279 **Vulnerability Type**: Sensitive information disclosure through remote job records **Risk Level**: Medium ### Vulnerable Code ```python def generate_config_script(config): api_base = config['api_base'] api_key = config['api_key'] model_name = config['model_name'] model_provider = config['model_provider'] test_script = '''#!/bin/bash set -e echo "[INFO] Configuring JiuwenSwarm model..." CONFIG_DIR="/root/.jiuwenswarm/config" ENV_FILE="$CONFIG_DIR/.env" # Define the four parameters to update API_BASE_VALUE="''' + api_base + '''" API_KEY_VALUE="''' + api_key + '''" MODEL_NAME_VALUE="''' + model_name + '''" MODEL_PROVIDER_VALUE="''' + model_provider + '''" update_param() { local key="$1" local value="$2" local env_file="$3" if grep -q "^[[:space:]]*$key=" "$env_file"; then sed -i "s|^\\s*$key=.*|$key=\"$value\"|" "$env_file" echo "[INFO] Updated $key" else echo "$key=\"$value\"" >> "$env_file" echo "[INFO] Added $key" fi } update_param "API_BASE" "$API_BASE_VALUE" "$ENV_FILE" update_param "API_KEY" "$API_KEY_VALUE" "$ENV_FILE" update_param "MODEL_NAME" "$MODEL_NAME_VALUE" "$ENV_FILE" update_param "MODEL_PROVIDER" "$MODEL_PROVIDER_VALUE" "$ENV_FILE" echo "[INFO] Config file updated:" echo "-----------------------------------------" cat "$ENV_FILE" echo "-----------------------------------------" chmod 600 "$ENV_FILE" ``` The generated script is submitted to Huawei Cloud COC as persistent script content by `create_and_execute_command()`: ```python request.body = AddScriptModel( name=script_name, type="SHELL", content=command, description=description, properties=properties ) ``` ### Technical Analysis The model API key is embedded directly in the generated shell script. That complete script is uploaded to COC when a script record is created. The remote script then prints th ...[truncated 1499 chars]
Remediation
## Remediation Suggestions 1. Remove the following diagnostic output entirely: ```bash cat "$ENV_FILE" ``` 2. Log only the names of updated settings, never their values. 3. Do not interpolate secrets into persistent COC script definitions. 4. Transfer secrets through a dedicated secret-management facility, encrypted parameter mechanism, or short-lived scoped credential channel that does not retain plaintext in script records. 5. Restrict COC script and job-read permissions according to least privilege. 6. Configure retention limits for existing COC scripts and execution logs. 7. Rotate model API keys that may already have appeared in COC content or output. 8. Add tests that reject generated scripts containing raw secret values or commands that print secret-bearing files.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/utils.py:57
Finding
Credential loader persistently disables Huawei Cloud credential encryption## Vulnerability Details **File Location**: `scripts/utils.py`, lines 57–91 **Vulnerability Type**: Plaintext credential persistence **Risk Level**: Medium ### Vulnerable Code ```python def _read_hcloud_config_credentials(): """ Read AK/SK/SecurityToken from hcloud CLI config file (~/.hcloud/config.json). If credentials are encrypted (authEncrypt=true), automatically disable encryption via 'hcloud configure set --cli-auth-encrypt=false' so plaintext values become readable. """ config_path = Path.home() / ".hcloud" / "config.json" if not config_path.exists(): return None try: with open(config_path, 'r', encoding='utf-8') as f: config = json.load(f) except (json.JSONDecodeError, IOError): return None # If credentials are encrypted, disable encryption so we can read plaintext. # hcloud will re-write config.json with unencrypted accessKeyId/secretAccessKey. if config.get("authEncrypt", "false") == "true": log.info( "hcloud config credentials are encrypted, " "disabling encryption to read plaintext..." ) try: subprocess.run( [ "hcloud", "configure", "set", "--cli-auth-encrypt=false" ], capture_output=True, text=True, timeout=10, ) # Re-read the config after hcloud has rewritten it with open(config_path, 'r', encoding='utf-8') as f: config = json.load(f) except Exception as e: log.warning(f"Failed to disable hcloud auth encryption: {e}") return None ``` ### Technical Analysis When the local hcloud profile uses encrypted credential storage, the Skill invokes hcloud to disable encryption globally for that configuration. The command rewrites `~/.hcloud/config.json` with plainte ...[truncated 1594 chars]
Remediation
## Remediation Suggestions 1. Do not disable hcloud credential encryption. 2. Use hcloud or the Huawei Cloud SDK as the credential provider without extracting plaintext credentials from the configuration file. 3. Prefer short-lived, least-privileged STS credentials for deployment operations. 4. If compatibility absolutely requires a temporary state change: - Obtain explicit user consent. - Record the original encryption state. - Re-enable encryption in a `finally` block. - Verify that plaintext copies and temporary files are removed. 5. Do not copy recovered credentials into long-lived process-global environment variables unless required. 6. Review filesystem and backup access to `~/.hcloud/config.json`. 7. Rotate any permanent credentials that have already been persistently decrypted.

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
scripts/deploy_service.py:378
Finding
Privileged remote deployment does not enforce the documented confirmation gate## Vulnerability Details **File Location**: `scripts/deploy_service.py`, lines 378–442 **Vulnerability Type**: Missing authorization confirmation for destructive privileged changes **Risk Level**: Medium The affected authorization requirement is documented in `SKILL.md`, lines 247–275. ### Vulnerable Code The entry point accepts a target and invokes deployment directly: ```python def parse_args(): parser = argparse.ArgumentParser( description='COC Remote Deployment of JiuwenSwarm Service' ) parser.add_argument( '--instance-id', type=str, help='Instance RMS resource ID' ) parser.add_argument( '--ecs-instance-id', type=str, help='ECS instance ID' ) parser.add_argument( '--ip', type=str, help='Instance public IP address' ) parser.add_argument( '--wait', action='store_true', default=True, help='Wait for deployment to complete' ) parser.add_argument( '--timeout', type=int, default=1799, help='Timeout in seconds (must be < 1800 per COC API limit)' ) return parser.parse_args() def main(): args = parse_args() if not os.environ.get('HUAWEICLOUD_SDK_AK') or not os.environ.get( 'HUAWEICLOUD_SDK_SK' ): print( "[ERROR] Please set environment variables " "HUAWEICLOUD_SDK_AK and HUAWEICLOUD_SDK_SK" ) sys.exit(1) get_credentials() instance_info = None if args.instance_id and args.ip: instance_info = { 'instance_id': args.instance_id, 'ecs_instance_id': args.ecs_instance_id, 'public_ip': args.ip, 'region': REGION } elif args.ip: print(f"[INFO] Querying instance info by public IP: {args.ip}") instance_info = query_instance_by_ip(args.ip) if not instance_info: print("[ERROR] Cannot find instance w ...[truncated 3207 chars]
Remediation
## Remediation Suggestions 1. Enforce confirmation in the executable rather than relying on documentation. 2. Before execution, display: - Account and project. - Region. - Instance ID, name, and public IP. - Planned package installation and file changes. - The systemd service that will be enabled. 3. Require an exact interactive confirmation phrase tied to the displayed target. 4. For noninteractive automation, require an explicit, auditable flag such as: ```text --confirm-target <instance-id> ``` The supplied value must exactly match the resolved instance ID. 5. Default to a dry-run or plan mode. 6. Consider requiring a separate confirmation for replacing existing configuration or service files. 7. Refuse to proceed when target identity is ambiguous or when the saved instance metadata is stale. 8. Use a non-root service account where possible and restrict COC execution privileges to the minimum required operations.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (92)

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding
This mismatch is security-significant because the documented purpose downplays or omits highly sensitive behaviors: reading local cloud credentials, disabling credential encryption, enumerating cloud resources, and creating/executing arbitrary remote COC scripts. That combination can materially change user consent and reviewer understanding, enabling covert credential exposure and unauthorized remote actions.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
This mismatch is security-significant because the documented purpose downplays or omits highly sensitive behaviors: reading local cloud credentials, disabling credential encryption, enumerating cloud resources, and creating/executing arbitrary remote COC scripts. That combination can materially change user consent and reviewer understanding, enabling covert credential exposure and unauthorized remote actions.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
This mismatch is security-significant because the documented purpose downplays or omits highly sensitive behaviors: reading local cloud credentials, disabling credential encryption, enumerating cloud resources, and creating/executing arbitrary remote COC scripts. That combination can materially change user consent and reviewer understanding, enabling covert credential exposure and unauthorized remote actions.

Credential Access

High
Category
Privilege Escalation
Content
client_secret: ""
    allow_from: "*"

# Model Configuration (read from .env file)
model:
  api_base: ${API_BASE}
  api_key: ${API_KEY}
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
client_secret: ""
    allow_from: "*"

# Model Configuration (read from .env file)
model:
  api_base: ${API_BASE}
  api_key: ${API_KEY}
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
client_secret: ""
    allow_from: "*"

# Model Configuration (read from .env file)
model:
  api_base: ${API_BASE}
  api_key: ${API_KEY}
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
client_secret: ""
    allow_from: "*"

# Model Configuration (read from .env file)
model:
  api_base: ${API_BASE}
  api_key: ${API_KEY}
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
client_secret: ""
    allow_from: "*"

# Model Configuration (read from .env file)
model:
  api_base: ${API_BASE}
  api_key: ${API_KEY}
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
client_secret: ""
    allow_from: "*"

# Model Configuration (read from .env file)
model:
  api_base: ${API_BASE}
  api_key: ${API_KEY}
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
client_secret: ""
    allow_from: "*"

# Model Configuration (read from .env file)
model:
  api_base: ${API_BASE}
  api_key: ${API_KEY}
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
client_secret: ""
    allow_from: "*"

# Model Configuration (read from .env file)
model:
  api_base: ${API_BASE}
  api_key: ${API_KEY}
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
client_secret: ""
    allow_from: "*"

# Model Configuration (read from .env file)
model:
  api_base: ${API_BASE}
  api_key: ${API_KEY}
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
client_secret: ""
    allow_from: "*"

# Model Configuration (read from .env file)
model:
  api_base: ${API_BASE}
  api_key: ${API_KEY}
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
client_secret: ""
    allow_from: "*"

# Model Configuration (read from .env file)
model:
  api_base: ${API_BASE}
  api_key: ${API_KEY}
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
client_secret: ""
    allow_from: "*"

# Model Configuration (read from .env file)
model:
  api_base: ${API_BASE}
  api_key: ${API_KEY}
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
client_secret: ""
    allow_from: "*"

# Model Configuration (read from .env file)
model:
  api_base: ${API_BASE}
  api_key: ${API_KEY}
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
client_secret: ""
    allow_from: "*"

# Model Configuration (read from .env file)
model:
  api_base: ${API_BASE}
  api_key: ${API_KEY}
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
client_secret: ""
    allow_from: "*"

# Model Configuration (read from .env file)
model:
  api_base: ${API_BASE}
  api_key: ${API_KEY}
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
client_secret: ""
    allow_from: "*"

# Model Configuration (read from .env file)
model:
  api_base: ${API_BASE}
  api_key: ${API_KEY}
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
rate_limit: 100
CONFIGEOF

cat > /root/.jiuwenswarm/config/.env << 'ENVEOL'
API_BASE=https://api.openai.com/v1
API_KEY=your-api-key-here
MODEL_NAME=gpt-4
Confidence
93% confidence
Finding
The script creates a secrets-bearing .env file with a placeholder API key and later uses it to start a root-run service. This pattern encourages storing long-lived credentials in plaintext on disk, increasing the blast radius if the host or root-owned service is compromised.

Credential Access

High
Category
Privilege Escalation
Content
User=root
Group=root
WorkingDirectory=/opt/jiuwenswarm-env
EnvironmentFile=/root/.jiuwenswarm/config/.env
ExecStart=/opt/jiuwenswarm-env/bin/jiuwenswarm-start
Restart=always
RestartSec=5
Confidence
95% confidence
Finding
Loading secrets from /root/.jiuwenswarm/config/.env into a systemd service that runs as root concentrates both credentials and execution privilege in the same process. If the application is compromised, an attacker may gain access to API keys and root-level execution context, significantly increasing impact.

Credential Access

High
Category
Privilege Escalation
Content
**Solutions**:
```bash
# View configuration file
cat /opt/jiuwenswarm-env/jiuwenswarm/.env

# Test API connection
curl -v -H "Authorization: Bearer <api_key>" <api_base>/models
Confidence
94% confidence
Finding
This command tells users to display the full .env file, which is a direct exposure path for API keys and other secrets. In this skill's context—deploying AI platforms and configuring model providers—those secrets are highly likely to be present and valuable if leaked.

Missing User Warnings

High
Confidence
93% confidence
Finding
The guide includes a ready-to-run instance deletion API call without a prominent warning that the action is destructive and may permanently remove compute resources and associated data. In an infrastructure deployment skill, this can lead to accidental service outage or data loss if copied during troubleshooting.

Missing User Warnings

High
Confidence
99% confidence
Finding
The generated scripts write API secrets into /root/.jiuwenswarm/config/config.yaml and then set permissions to 644, making the file world-readable to all local users. This exposes long-lived credentials such as AK/SK, Feishu app secrets, and DingTalk client secrets to any user or process on the host, enabling credential theft and downstream account compromise.

Missing User Warnings

High
Confidence
99% confidence
Finding
The generated shell script runs `cat "$ENV_FILE"` after writing configuration, which will print the API key and other secrets contained in the `.env` file to execution output. In this skill's context, commands are executed through Huawei Cloud COC, so the secret may be exposed in remote job logs, consoles, or auditing systems accessible beyond the instance itself.

Static analysis

Detected: suspicious.exposed_secret_literal

File appears to expose a hardcoded API secret or token.

Critical
Code
suspicious.exposed_secret_literal
Location
scripts/utils.py:210