Back to skill

Security audit

MGC Cross-Region Migration

Security checks for vulnerabilities and agentic risk

Overview

This migration skill needs review because it can expose administrator passwords, leave root access enabled, and delete servers outside the current repair.

Have an administrator review and fix the cleanup, password handling, SSH verification, and rollback behavior before production use. Use isolated migration resources, narrowly scoped credentials, backups, and explicit target IDs. Require approval for project changes, password resets, restarts, and deletions. If already used, rotate repair passwords and verify migration-key removal and SSH/firewall restoration. Review covered the scanner's partial lessons reference and executable risk paths; live cloud effects and checkpoint recovery remain untested.

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 (4)

T09 · Insecure Skill Coding Practices

Error
Location
.
Finding

Migration SSH connections authenticate to unverified hosts

Content
View full analysis

Impact

An impersonating SSH server can receive source or destination passwords. Intercepted destination connections can also receive migrated data; substituted source connections can supply attacker-controlled migration content.

T09 · Insecure Skill Coding Practices

Error
Location
.
Finding

Boot repair automatically deletes unrelated prefix-matching servers and volumes

Content
View full analysis

Impact

An unrelated stopped server with a matching name can be permanently deleted along with its attached volume and public IP.

T09 · Insecure Skill Coding Practices

Warning
Location
.
Finding

SSH recovery resets passwords and hard-reboots before its explicit opt-in gate

Content
View full analysis

Impact

An existing reused target can have its login credential changed and be forcibly restarted even when the SSH-bootstrap confirmation flag is absent.

T09 · Insecure Skill Coding Practices

Warning
Location
.
Finding

AWS migration scripts create persistent Internet-wide SSH ingress

Content
View full analysis

Impact

The target's password-enabled SSH service remains publicly reachable. In the reused-group case, existing associated hosts can also lose their prior SSH source restrictions. This establishes unauthorized network exposure, not an authentication bypass or proven compromise.

Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Output HandlingUnvalidated Output Injection, Cross-Context Output, Unbounded Output
  • YARA SignaturesMalware Match, Webshell Match, Cryptominer Match
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (78)

Description-Behavior Mismatch

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding

The documented boot-repair path enables PermitRootLogin yes, PasswordAuthentication yes, and cloud-init password authentication without specifying restoration, weakening the target's authentication policy beyond a boot repair. These changes are disclosed in the document, so concealment is not established, and the alleged plaintext repair-artifact disclosure cannot be verified without the implementation; nevertheless, the persistent authentication weakening is supported and can expose root access on reachable hosts.

Content

No source excerpt is available for this finding.

Incomplete referenced artifact analysis

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 180)May include surrounding context.

md
过程的问题总结", "经验复盘", "踩坑记录", or "postmortem", load [references/lessons-learned.md](references/lessons-learned.md) and report in this order:

Incomplete referenced artifact analysis

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 194)May include surrounding context.

md
- [references/lessons-learned.md](references/lessons-learned.md) — structured migration issue summary (`symptom -> root cause -> action -> prevention`) and reus

The force-kill instruction lacks a warning about interrupting active migration processes.

High
Category
Output Handling
Confidence
97% confidence
Finding

The root-level pkill -9 -f linuxmain command kills every matching command line rather than only a verified stale agent PID. A deleted working directory does not prove that a migration is inactive, and SIGKILL prevents graceful cleanup, potentially interrupting active transfers or leaving tasks inconsistent.

Content

No source excerpt is available for this finding.

The cutover phase disables the source SSH service rather than quiescing application writes, disrupting the transport required for migration and source administration.

High
Category
Excessive Agency
Confidence
100% confidence
Finding

Cutover stops sshd on the source and then attempts a new SSH-based rsync connection, potentially disabling both migration transport and remote administration. It does not stop application writers, so it also fails to establish a consistent cutover point, and no automatic SSH restoration is provided.

Content

No source excerpt is available for this finding.

Automatically switches enterprise projects to continue provisioning after a budget denial.

High
Category
Excessive Agency
Confidence
98% confidence
Finding

After an enterprise-project budget denial, provisioning automatically retries against other project candidates, including the default project or an omitted project. With broadly scoped cloud credentials, this can defeat the intended spending boundary and charge resources to a different governance scope without explicit approval.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
90% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/mgc_migrate.py (reported line 3703)May include surrounding context.

python
inject_key_cmd = (
        "set -e; "
        "mkdir -p /root/.ssh; chmod 700 /root/.ssh; "
        "touch /root/.ssh/authorized_keys; chmod 600 /root/.ssh/authorized_keys; "
        "KEY={pub}; "
        "ALREADY=0; grep -qxF \"$KEY\" /root/.ssh/authorized_keys && ALREADY=1; "
        "grep -qxF \"$KEY\" /root/.ssh/authorized_keys || echo \"$KEY\" >> /root/.ssh/authorized_keys; "

Credential Access

High
Category
Privilege Escalation
Confidence
90% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/mgc_migrate.py (reported line 3703)May include surrounding context.

python
inject_key_cmd = (
        "set -e; "
        "mkdir -p /root/.ssh; chmod 700 /root/.ssh; "
        "touch /root/.ssh/authorized_keys; chmod 600 /root/.ssh/authorized_keys; "
        "KEY={pub}; "
        "ALREADY=0; grep -qxF \"$KEY\" /root/.ssh/authorized_keys && ALREADY=1; "
        "grep -qxF \"$KEY\" /root/.ssh/authorized_keys || echo \"$KEY\" >> /root/.ssh/authorized_keys; "

Credential Access

High
Category
Privilege Escalation
Confidence
90% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/mgc_migrate.py (reported line 3705)May include surrounding context.

python
"mkdir -p /root/.ssh; chmod 700 /root/.ssh; "
        "touch /root/.ssh/authorized_keys; chmod 600 /root/.ssh/authorized_keys; "
        "KEY={pub}; "
        "ALREADY=0; grep -qxF \"$KEY\" /root/.ssh/authorized_keys && ALREADY=1; "
        "grep -qxF \"$KEY\" /root/.ssh/authorized_keys || echo \"$KEY\" >> /root/.ssh/authorized_keys; "
        "ORIG_PWAUTH=$(grep -i '^PasswordAuthentication[[:space:]]' /etc/ssh/sshd_config | tail -n1); "
        "ORIG_ROOTLOGIN=$(grep -i '^PermitRootLogin[[:space:]]' /etc/ssh/sshd_config | tail -n1); "

Credential Access

High
Category
Privilege Escalation
Confidence
98% confidence
Finding

Adding a source-held key to root's authorized_keys is legitimate only while the approved migration access is required. The lifecycle is unsafe: insertion occurs before bootstrap state is returned, and the cleanup command fails to replace authorized_keys when filtering its sole entry, potentially leaving root access available to the source indefinitely.

Content

Scanner excerpt · scripts/mgc_migrate.py (reported line 3706)May include surrounding context.

python
"touch /root/.ssh/authorized_keys; chmod 600 /root/.ssh/authorized_keys; "
        "KEY={pub}; "
        "ALREADY=0; grep -qxF \"$KEY\" /root/.ssh/authorized_keys && ALREADY=1; "
        "grep -qxF \"$KEY\" /root/.ssh/authorized_keys || echo \"$KEY\" >> /root/.ssh/authorized_keys; "
        "ORIG_PWAUTH=$(grep -i '^PasswordAuthentication[[:space:]]' /etc/ssh/sshd_config | tail -n1); "
        "ORIG_ROOTLOGIN=$(grep -i '^PermitRootLogin[[:space:]]' /etc/ssh/sshd_config | tail -n1); "
        "sed -ri 's/^#?PasswordAuthentication\\s+.*/PasswordAuthentication yes/' /etc/ssh/sshd_config || true; "

Credential Access

High
Category
Privilege Escalation
Confidence
98% confidence
Finding

This duplicates the key-insertion vulnerability rather than indicating a second backdoor. Explicit opt-in reduces concern about malicious intent, but does not prevent persistent root access when rollback state is lost or the defective removal command leaves the key installed.

Content

Scanner excerpt · scripts/mgc_migrate.py (reported line 3706)May include surrounding context.

python
"touch /root/.ssh/authorized_keys; chmod 600 /root/.ssh/authorized_keys; "
        "KEY={pub}; "
        "ALREADY=0; grep -qxF \"$KEY\" /root/.ssh/authorized_keys && ALREADY=1; "
        "grep -qxF \"$KEY\" /root/.ssh/authorized_keys || echo \"$KEY\" >> /root/.ssh/authorized_keys; "
        "ORIG_PWAUTH=$(grep -i '^PasswordAuthentication[[:space:]]' /etc/ssh/sshd_config | tail -n1); "
        "ORIG_ROOTLOGIN=$(grep -i '^PermitRootLogin[[:space:]]' /etc/ssh/sshd_config | tail -n1); "
        "sed -ri 's/^#?PasswordAuthentication\\s+.*/PasswordAuthentication yes/' /etc/ssh/sshd_config || true; "

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

High
Category
YARA Match
Confidence
98% confidence
Finding

The YARA label overstates the evidence of malware: the public key is generated on the migration source and insertion requires explicit opt-in. Nevertheless, the insertion creates unrestricted root authorization whose rollback can fail, especially because the cleanup pipeline retains a sole migration-key entry, making this a real residual-access vulnerability.

Content

Scanner excerpt · scripts/mgc_migrate.py (reported line 3706)May include surrounding context.

python
ootstrap() can restore the original state after migration.
    inject_key_cmd = (
        "set -e; "
        "mkdir -p /root/.ssh; chmod 700 /root/.ssh; "
        "touch /root/.ssh/authorized_keys; chmod 600 /root/.ssh/authorized_keys; "
        "KEY={pub}; "
        "ALREADY=0; grep -qxF \"$KEY\" /root/.ssh/authorized_keys && ALREADY=1; "
        "grep -qxF \"$KEY\" /root/.ssh/authorized_keys || echo \"$KEY\" >> /root/.ssh/authorized_keys; "
        "ORIG_PWAUTH=$(grep -i '^PasswordAuthentication[[:space:]]' /etc/ssh/sshd_config | tail -n1); "
        "ORIG_ROOTLOGIN=$(grep -i '^PermitRootLogin[[:space:]]' /etc/ssh/sshd_config | tail -n1); "
        "sed -ri 's/^#?PasswordAuthentication\\s+.*/PasswordAuthentication yes/' /etc/ssh/sshd_config || true; "
        "grep -q '^PasswordAuthentication\\s\\+yes' /etc/ssh/sshd_config || echo 'PasswordAuthentication yes' >> /etc/ssh/sshd_config; "
        "sed -ri 's/^#?PermitRootLogin\\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config || true; "

Credential Access

High
Category
Privilege Escalation
Confidence
100% confidence
Finding

grep -vxF returns exit status 1 when removing the migration key leaves no lines. Because replacement is conditional on grep succeeding, an authorized_keys file containing only that key is never replaced, and the trailing '|| true' suppresses the failure while root access remains enabled.

Content

Scanner excerpt · scripts/mgc_migrate.py (reported line 3797)May include surrounding context.

python
if not already_present:
        remove_key_part = (
            "KEY={pub}; "
            "grep -vxF \"$KEY\" /root/.ssh/authorized_keys > /root/.ssh/authorized_keys.mgc_tmp 2>/dev/null "
            "&& mv /root/.ssh/authorized_keys.mgc_tmp /root/.ssh/authorized_keys || true; "
        ).format(pub=shlex.quote(source_pubkey))

Credential Access

High
Category
Privilege Escalation
Confidence
100% confidence
Finding

This is another match on the defective key-removal pipeline. When the migration key is the only entry, grep produces an empty result with status 1, skips mv, and leaves the original root authorization intact.

Content

Scanner excerpt · scripts/mgc_migrate.py (reported line 3797)May include surrounding context.

python
if not already_present:
        remove_key_part = (
            "KEY={pub}; "
            "grep -vxF \"$KEY\" /root/.ssh/authorized_keys > /root/.ssh/authorized_keys.mgc_tmp 2>/dev/null "
            "&& mv /root/.ssh/authorized_keys.mgc_tmp /root/.ssh/authorized_keys || true; "
        ).format(pub=shlex.quote(source_pubkey))

Credential Access

High
Category
Privilege Escalation
Confidence
100% confidence
Finding

The mv operation is gated by grep's success status, which incorrectly excludes the valid empty-file result. Its broad error suppression also makes failed revocation appear successful, extending source-to-target root access beyond the migration.

Content

Scanner excerpt · scripts/mgc_migrate.py (reported line 3798)May include surrounding context.

python
remove_key_part = (
            "KEY={pub}; "
            "grep -vxF \"$KEY\" /root/.ssh/authorized_keys > /root/.ssh/authorized_keys.mgc_tmp 2>/dev/null "
            "&& mv /root/.ssh/authorized_keys.mgc_tmp /root/.ssh/authorized_keys || true; "
        ).format(pub=shlex.quote(source_pubkey))

    restore_pwauth = "sed -ri '/^PasswordAuthentication[[:space:]]/d' /etc/ssh/sshd_config; "

Credential Access

High
Category
Privilege Escalation
Confidence
100% confidence
Finding

This duplicates the cleanup defect: conditional replacement retains the original file when removing its only key. The result is residual root authorization, not credential extraction, and is particularly dangerous if the source server is later compromised.

Content

Scanner excerpt · scripts/mgc_migrate.py (reported line 3798)May include surrounding context.

python
remove_key_part = (
            "KEY={pub}; "
            "grep -vxF \"$KEY\" /root/.ssh/authorized_keys > /root/.ssh/authorized_keys.mgc_tmp 2>/dev/null "
            "&& mv /root/.ssh/authorized_keys.mgc_tmp /root/.ssh/authorized_keys || true; "
        ).format(pub=shlex.quote(source_pubkey))

    restore_pwauth = "sed -ri '/^PasswordAuthentication[[:space:]]/d' /etc/ssh/sshd_config; "

Boot repair persistently enables root password SSH access on the target.

High
Category
Excessive Agency
Confidence
100% confidence
Finding

Boot repair persistently enables root password authentication, unlocks root, and rewrites SSH and cloud-init policy without restoring the original settings. This unnecessarily expands privileged remote access, and the script also records the reset password in report files and stdout, increasing the consequences of that policy change.

Content

No source excerpt is available for this finding.

Default cleanup can delete unrelated instances and volumes across the project.

High
Category
Excessive Agency
Confidence
99% confidence
Finding

Default cleanup selects instances across the project using only a boot-repair- name prefix, shutdown status, and attached-volume count. Those checks do not establish ownership, so unrelated matching instances and their volumes can be permanently deleted using the operator's cloud permissions.

Content

No source excerpt is available for this finding.

Autonomous Decision Making

Medium
Category
Excessive Agency
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.

Content

Scanner excerpt · README.md (reported line 27)May include surrounding context.

cp terraform.tfvars.example terraform.tfvars

edit terraform.tfvars

terraform init terraform apply -auto-approve

text

Result file:

Autonomous Decision Making

Medium
Category
Excessive Agency
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.

Content

Scanner excerpt · references/runbook.md (reported line 123)May include surrounding context.

md
- `VPC.0114`
  - Meaning: target-region VPC/router quota exceeded when creating target VPC.
  - Action: release one unused VPC or increase quota, then rerun `terraform apply -auto-approve`.

- `SMS.7703`
  - Meaning: queried `task_id` does not exist (often from stale historical output file).

Autonomous Decision Making

Medium
Category
Excessive Agency
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.

Content

Scanner excerpt · README.md (reported line 48)May include surrounding context.

md
- `VPC.0114`
  - Meaning: target region VPC quota exceeded when creating `vpc-migration`.
  - Action: delete an unused VPC or increase quota, then rerun `terraform apply -auto-approve`.

- `SMS.7703`
  - Meaning: queried `task_id` does not exist (commonly a stale ID from older output).

Autonomous Decision Making

Medium
Category
Excessive Agency
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.

Content

Scanner excerpt · references/lessons-learned.md (reported line 16)May include surrounding context.

md
- Symptom: `terraform apply` fails while creating target VPC (`vpc-migration`) in `la-south-2`.
- Root cause: target-region VPC quota is full (`used == quota`).
- Corrective action: delete one unused VPC or increase VPC quota, then rerun `terraform apply -auto-approve`.
- Prevention: check VPC quota before every apply when VPC may be auto-created.

### `SMS.7703` (task does not exist)

Autonomous Decision Making

Medium
Category
Excessive Agency
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.

Content

Scanner excerpt · references/migration-skill-summary.md (reported line 17)May include surrounding context.

md
1. Validate source registration/permissions/target image/quota.
2. Populate `terraform.tfvars` with migration, network, and optional VPN/rsync parameters.
3. Run `terraform init` then `terraform apply -auto-approve`.
4. If apply reports `No changes`, force rerun with:
   - `terraform apply -replace=terraform_data.sms_existing_target_batch -auto-approve`
5. Confirm run output from:

Autonomous Decision Making

Medium
Category
Excessive Agency
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.

Content

Scanner excerpt · references/reuse-bundle.md (reported line 23)May include surrounding context.

bash
cd skills/migrationom/oos/huawei-cloud-mgc-migration-ecs-gcp-to-hw
terraform init
terraform apply -auto-approve
terraform apply -replace=terraform_data.mgc_region_migration -auto-approve
cat out/migration_result.json
cat out/precheck_task_cleanup.json

Autonomous Decision Making

Medium
Category
Excessive Agency
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.

Content

Scanner excerpt · references/runbook.md (reported line 117)May include surrounding context.

md
- `SMS.8115`
  - Meaning: migration-project quota reached (max 50).
  - Action: delete old migration projects (prefer auto-generated `mgc*` projects), then rerun `terraform apply -auto-approve`.
  - Helper: `python3 scripts/mgc_cleanup_migprojects.py` (dry-run) / `python3 scripts/mgc_cleanup_migprojects.py --apply`.
  - Limitation: the default project (`isdefault=true`) cannot be deleted via the API (`HTTP 400 SMS.7303`); set another project as default in the SMS/MgC console first.