Back to skill

Security audit

huawei-cloud-ecs-passwordless-login

Security checks for vulnerabilities and agentic risk

Overview

This skill needs Review because it grants broad cloud and SSH access, then intentionally keeps SSH sessions usable after key cleanup.

Install only for a deliberate administrative workflow where you are comfortable granting the agent Huawei Cloud COC/IAM authority and SSH access to the selected ECS hosts. Before use, remove or opt out of the post-cleanup ControlMaster persistence, avoid root where possible, validate or create a unique per-run COC script, keep batches small, verify SSH host keys, and clean up ~/.ssh/config entries and control sockets afterward.

Vulnerability Patterns
  • Tool Hijacking and SpoofingModifies or replaces tools so legitimate-looking calls execute attacker logic
  • 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)

T07 · Tool Hijacking and Spoofing

Error
Location
SKILL.md:69
Finding
Unverified Reusable COC Script Is Executed as Root## Vulnerability Details **File Location**: `SKILL.md`, lines 69 and 226–231 **Vulnerability Type**: Untrusted COC script reuse leading to privileged remote code execution **Risk Level**: High **Relevant Code:** ```markdown 1. **Check existing** — Call `ListScripts --cli-region=<coc_region>` with `--name_like="coc_ssh_key_setup"`. If found, record `script_uuid` and skip step 2. ``` ```json "execute_param": { "execute_user": "root", "success_rate": 100, "timeout": 120, "script_params": [{ ``` ```bash hcloud COC ExecuteScript --cli-region=<coc_region> \ --cli-jsonInput=<temp_dir>/coc_execute.json ``` ### Technical Analysis The Skill searches for an existing COC script using the fuzzy `name_like` filter and instructs the agent to reuse the returned `script_uuid`. It does not require validation of the script's exact name, owner, type, body, version, parameters, or digest before execution. The reused script is subsequently executed with `execute_user` set to `root` on all selected ECS targets. Therefore, a COC principal able to create or modify scripts can place a matching document containing attacker-selected commands. The Skill then treats that document as trusted solely because its name matches the search. This crosses the trust boundary between COC content controlled by another account principal and privileged execution on the operator's ECS instances. It constitutes a tool/API hijacking vulnerability rather than evidence that the Skill author intended to compromise systems. ### Attack Path 1. An attacker obtains permission within the same cloud account to create or modify COC scripts, without necessarily having direct root access to the target ECS instances. 2. The attacker creates a malicious COC shell script with a name matching `coc_ssh_key_setup`, or modifies an existing matching script. 3. A user invokes the Skill for legitimate ECS targets. 4. The Skill calls `ListScripts` with `--name_like="coc_ssh_key_setup"`. 5. The malicious or mod ...[truncated 882 chars]
Remediation
## Remediation Suggestions - Do not reuse a script based only on a fuzzy name match. - Prefer creating a uniquely named, per-run COC script and deleting it after execution. - If reuse is required, retrieve the complete script definition and verify: - Exact script name - Expected owner or creator - Script type - Canonical script body or a pinned cryptographic digest - Exact parameter names, sensitivity flags, and schema - Expected version and execution policy - Reject ambiguous results and refuse execution when multiple scripts match. - Never execute an existing script as root unless all integrity checks succeed. - Where operationally possible, use a dedicated least-privileged execution account rather than `root`. - Ensure permissions to create and modify reusable COC documents are restricted and separated from permissions to invoke this workflow.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
Findings (33)

Ssd 4

High
Confidence
99% confidence
Finding
The workflow establishes a persistent session first and then removes the obvious authentication artifact, creating a deceptive appearance that access was cleaned up. This pattern is more dangerous than ordinary temporary key deployment because it conceals retained access behind security-oriented language.

Context-Inappropriate Capability

High
Confidence
99% confidence
Finding
Maintaining continued SSH access after credential cleanup is not necessary to accomplish temporary passwordless login setup and instead introduces covert persistence. In context, the skill intentionally preserves a live authenticated channel after deleting the key, which can be used to retain unauthorized access while presenting an appearance of cleanup.

Ssd 4

High
Confidence
99% confidence
Finding
The cleanup section frames the process as a mandatory security measure while explicitly preserving connectivity after key deletion. That mismatch masks persistence as hygiene, which can enable prolonged unauthorized access and undermine operator expectations, auditability, and incident response.

Credential Access

High
Category
Privilege Escalation
Content
"name": "coc_ssh_key_setup",
    "type": "SHELL",
    "description": "Deploy SSH public key for passwordless login",
    "content": "#!/bin/bash\nset -e\nHOME_DIR=$(eval echo ~$SSH_USER)\nmkdir -p \"$HOME_DIR/.ssh\" && chmod 700 \"$HOME_DIR/.ssh\"\necho $PUBLIC_KEY >> \"$HOME_DIR/.ssh/authorized_keys\"\nchmod 600 \"$HOME_DIR/.ssh/authorized_keys\"\necho KEY_DEPLOYED_SUCCESSFULLY",
    "properties": {
      "risk_level": "LOW",
      "version": "1.0.0"
Confidence
96% confidence
Finding
The script appends a supplied public key directly into a remote user's authorized_keys, granting SSH access to the target account, with root as the default execute_user elsewhere in the workflow. In context, this is a high-risk credential-deployment capability that becomes more dangerous because the skill automates batch targeting and then preserves access after apparent cleanup.

YARA rule 'backdoor_persistence': Backdoor persistence with malicious payloads (shell commands, SSH key injection, hidden root users) [malware]

High
Category
YARA Match
Content
(coc_region)
hcloud COC ListScripts --cli-region=<coc_region> --limit=100 --name_like="coc_ssh_key_setup"
# If not found, create a JSON file and use --cli-jsonInput:
cat > <temp_dir>/coc_create.json << 'JSONEOF'
{
  "body": {
    "name": "coc_ssh_key_setup",
    "type": "SHELL",
    "description": "Deploy SSH public key for passwordless login",
    "content": "#!/bin/bash\nset -e\nHOME_DIR=$(eval echo ~$SSH_USER)\nmkdir -p \"$HOME_DIR/.ssh\" && chmod 700 \"$HOME_DIR/.ssh\"\necho $PUBLIC_KEY >> \"$HOME_DIR/.ssh/authorized_keys\"\nchmod 600 \"$HOME_DIR/.ssh/authorized_keys\"\necho KEY_DEPLOYED_SUCCESSFULLY",
    "properties": {
      "risk_level": "LOW",
      "version": "1.0.0"
    },
    "script_params": [
      {
        "param_name": "PUBLIC_KEY",
        "param_description": "SSH public key to deploy",
        "param_value": "",
        "sensitive": true
      },
      {
        "param_name": "SSH_USER",
        "param_description": "Target SSH username on the ECS",
        "param_v
Confidence
97% confidence
Finding
The YARA hit is justified in context because the skill contains a scripted SSH key injection into authorized_keys, a classic persistence mechanism, and combines it with later concealment of continued access through ControlMaster. While key deployment can be legitimate in isolation, the surrounding workflow's deliberate post-cleanup persistence makes this materially suspicious and dangerous.

Missing User Warnings

High
Confidence
99% confidence
Finding
The SSH commands disable host key verification and discard known_hosts state, removing an important protection against man-in-the-middle attacks. In a credential-deployment workflow, this is especially dangerous because the skill is establishing privileged remote access and could connect to an attacker-controlled host without warning.

Credential Access

High
Category
Privilege Escalation
Content
| `ecs_ip`          | Conditional | None         | Comma-separated list of ECS elastic IPv4 addresses. Required if `ecs_instance_id` is not provided. May be mixed with `ecs_instance_id` entries                                                                                         |
| `ecs_region`      | No          | None         | **Removed from target resolution.** Target ECS regions are discovered via `COC ListResources` (which returns each resource's `region_id` without needing it in advance); this parameter is kept only as an optional hint and is **not required** |
| `coc_region`      | No          | `cn-north-4` | **COC service region**. COC is a **global-level** service — only `cn-north-4` (China site) and `ap-southeast-3` (International site) are supported. All COC/IAM API calls must target this region; it is independent of the ECS region |
| `ssh_user`        | No          | `root`       | SSH username on the target ECS. Root or non-root supported; key is deployed to the user's `~/.ssh/authorized_keys`                                                                                                                     |
| `cleanup_delay`   | No          | `60`         | Seconds to wait before automatic key cleanup (min 10, max 300)                                                                                                                                                                         |
| `persist_timeout` | No          | `3600`       | Seconds to keep ControlMaster alive after all sessions close (min 60, max 86400)                                                                                                                                                       |
Confidence
90% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
## SSH Connectivity

- [ ] Non-root `ssh_user` supported: key deployed to `~<ssh_user>/.ssh/authorized_keys` (not just `/root`)
- [ ] Each target `ssh -i <temp_dir>/coc_ssh_key <ssh_user>@<EIP>` connects without password prompt
- [ ] Test command returns `SSH_OK` for every target
- [ ] SSH connection string provided to user for each target
Confidence
90% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
## SSH Connectivity

- [ ] Non-root `ssh_user` supported: key deployed to `~<ssh_user>/.ssh/authorized_keys` (not just `/root`)
- [ ] Each target `ssh -i <temp_dir>/coc_ssh_key <ssh_user>@<EIP>` connects without password prompt
- [ ] Test command returns `SSH_OK` for every target
- [ ] SSH connection string provided to user for each target
Confidence
90% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
## SSH Connectivity

- [ ] Non-root `ssh_user` supported: key deployed to `~<ssh_user>/.ssh/authorized_keys` (not just `/root`)
- [ ] Each target `ssh -i <temp_dir>/coc_ssh_key <ssh_user>@<EIP>` connects without password prompt
- [ ] Test command returns `SSH_OK` for every target
- [ ] SSH connection string provided to user for each target
Confidence
90% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
## SSH Connectivity

- [ ] Non-root `ssh_user` supported: key deployed to `~<ssh_user>/.ssh/authorized_keys` (not just `/root`)
- [ ] Each target `ssh -i <temp_dir>/coc_ssh_key <ssh_user>@<EIP>` connects without password prompt
- [ ] Test command returns `SSH_OK` for every target
- [ ] SSH connection string provided to user for each target
Confidence
90% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
## SSH Connectivity

- [ ] Non-root `ssh_user` supported: key deployed to `~<ssh_user>/.ssh/authorized_keys` (not just `/root`)
- [ ] Each target `ssh -i <temp_dir>/coc_ssh_key <ssh_user>@<EIP>` connects without password prompt
- [ ] Test command returns `SSH_OK` for every target
- [ ] SSH connection string provided to user for each target
Confidence
90% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Vague Triggers

Medium
Confidence
93% confidence
Finding
The manifest-style trigger list includes generic phrases such as "COC SSH" and "passwordless SSH" without constraints on context, actor intent, or negative examples. These phrases are broad enough to overlap with ordinary discussion of SSH setup and make it unclear when this specific destructive/credential-affecting workflow should activate versus when it should not.

Description-Behavior Mismatch

Medium
Confidence
98% confidence
Finding
The workflow claims to remove keys as a security cleanup measure, but immediately preserves access through SSH ControlMaster sessions that survive key removal. This creates misleading post-cleanup persistence: the visible credential artifact is removed while practical access remains, which is dangerous in an automation skill because operators may falsely believe access has been terminated.

Autonomous Decision Making

Medium
Category
Excessive Agency
Content
4. **Script Execution** — Execute the script on one or many target ECS instances via COC (batch; each target's region and resource_id are resolved via the COC CLI `ListResources`)
5. **SSH Test** — Verify passwordless SSH connection to every target ECS
6. **Persistent Connection** — Establish SSH ControlMaster so the agent can continue SSH access after keys are cleaned up
7. **Security Cleanup** — After 60 seconds, automatically remove keys from remote `authorized_keys`, delete the local key pair, and clean up the COC script

**Tool chain:** hcloud CLI (KooCLI) + local SSH tools. Deployment is handled through COC script execution only.
Confidence
80% 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.

Context-Inappropriate Capability

Medium
Confidence
94% confidence
Finding
The skill appends persistent entries to ~/.ssh/config and explicitly says they do not need cleanup, causing lasting local configuration changes beyond the stated task. This can alter future SSH behavior, create confusion, and leave behind connection metadata or unsafe defaults on the operator workstation.

Missing User Warnings

Medium
Confidence
91% confidence
Finding
The document normalizes persistent SSH client configuration changes as harmless without clearly warning the user that their local SSH behavior is being modified. This increases the risk of hidden side effects and makes it easier for insecure settings or persistence mechanisms to remain unnoticed on the operator system.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
"name": "coc_ssh_key_setup",
    "type": "SHELL",
    "description": "Deploy SSH public key for passwordless login",
    "content": "#!/bin/bash\nset -e\nHOME_DIR=$(eval echo ~$SSH_USER)\nmkdir -p \"$HOME_DIR/.ssh\" && chmod 700 \"$HOME_DIR/.ssh\"\necho $PUBLIC_KEY >> \"$HOME_DIR/.ssh/authorized_keys\"\nchmod 600 \"$HOME_DIR/.ssh/authorized_keys\"\necho KEY_DEPLOYED_SUCCESSFULLY",
    "properties": {
      "risk_level": "LOW",
      "version": "1.0.0"
Confidence
80% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
"name": "coc_ssh_key_setup",
    "type": "SHELL",
    "description": "Deploy SSH public key for passwordless login",
    "content": "#!/bin/bash\nset -e\nHOME_DIR=$(eval echo ~$SSH_USER)\nmkdir -p \"$HOME_DIR/.ssh\" && chmod 700 \"$HOME_DIR/.ssh\"\necho $PUBLIC_KEY >> \"$HOME_DIR/.ssh/authorized_keys\"\nchmod 600 \"$HOME_DIR/.ssh/authorized_keys\"\necho KEY_DEPLOYED_SUCCESSFULLY",
    "properties": {
      "risk_level": "LOW",
      "version": "1.0.0"
Confidence
80% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Session Persistence

Medium
Category
Rogue Agent
Content
ssh <ssh_user>@$eip "echo SSH_MUX_OK"  # verify multiplexing works
done

# 7. Security cleanup (background, survives parent shell exit via nohup + disown)
nohup bash -c '
sleep <cleanup_delay>
# Remove public key from every remote target
Confidence
65% confidence
Finding
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Session Persistence

Medium
Category
Rogue Agent
Content
ssh <ssh_user>@$eip "echo SSH_MUX_OK"  # verify multiplexing works
done

# 7. Security cleanup (background, survives parent shell exit via nohup + disown)
nohup bash -c '
sleep <cleanup_delay>
# Remove public key from every remote target
Confidence
65% confidence
Finding
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Session Persistence

Medium
Category
Rogue Agent
Content
ssh <ssh_user>@$eip "echo SSH_MUX_OK"  # verify multiplexing works
done

# 7. Security cleanup (background, survives parent shell exit via nohup + disown)
nohup bash -c '
sleep <cleanup_delay>
# Remove public key from every remote target
Confidence
65% confidence
Finding
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Session Persistence

Medium
Category
Rogue Agent
Content
rm -f <temp_dir>/coc_ssh_key <temp_dir>/coc_ssh_key.pub
echo "COC SSH keys cleaned up. Existing SSH sessions remain unaffected."
' > <temp_dir>/coc_cleanup.log 2>&1 &
disown
echo "Cleanup scheduled in <cleanup_delay>s (PID: $!, log: <temp_dir>/coc_cleanup.log)"
```
Confidence
65% confidence
Finding
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Whitespace Padding

Medium
Category
Prompt Injection
Content
## Parameters

| Parameter         | Required    | Default      | Constraint                                                                                                                                                                                                                             |
| ----------------- | ----------- | ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ecs_instance_id` | Conditional | None         | Comma-separated list of ECS instance UUIDs. Required if `ecs_ip` is not provided. May be mixed with `ecs_ip` entries — the full set is the batch                                                                                       |
| `ecs_ip`          | Conditional | None         | Comma-separated list of ECS elastic IPv4 addresses. Required if `ecs_instance_id` is not provided. May be mixed with `ecs_instance_id` entries                                                                                         |
Confidence
70% confidence
Finding
Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.

Whitespace Padding

Medium
Category
Prompt Injection
Content
| Parameter         | Required    | Default      | Constraint                                                                                                                                                                                                                             |
| ----------------- | ----------- | ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ecs_instance_id` | Conditional | None         | Comma-separated list of ECS instance UUIDs. Required if `ecs_ip` is not provided. May be mixed with `ecs_ip` entries — the full set is the batch                                                                                       |
| `ecs_ip`          | Conditional | None         | Comma-separated list of ECS elastic IPv4 addresses. Required if `ecs_instance_id` is not provided. May be mixed with `ecs_instance_id` entries                                                                                         |
| `ecs_region`      | No          | None         | **Removed from target resolution.** Target ECS regions are discovered via `COC ListResources` (which returns each resource's `region_id` without needing it in advance); this parameter is kept only as an optional hint and is **not required** |
| `coc_region`      | No          | `cn-north-4` | **COC service region**. COC is a **global-level** service — only `cn-north-4` (China site) and `ap-southeast-3` (International site) are supported. All COC/IAM API calls must target this region; it is independent of the ECS region |
Confidence
70% confidence
Finding
Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.

Static analysis

No suspicious patterns detected.