T09 · Insecure Skill Coding Practices
- Location
src/tc_migrate/commands/generate_cmd.py:25- Finding
Terraform Preview Discloses Both Tencent Cloud SecretKeys
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This Tencent Cloud migration skill is mostly purpose-aligned, but it handles cloud credentials unsafely and makes Terraform deployment/security claims that are not fully supported by the packaged artifact.
Review before installing. Use only in a controlled workspace with least-privilege, short-lived Tencent Cloud credentials; avoid generate --preview with real secrets; do not pass SecretKeys on command lines; add account.yaml, tc-migrate.yaml, terraform.tfvars, tfplan, and Terraform state files to .gitignore; restrict file permissions; and confirm that the missing Terraform configuration is supplied and audited before running apply, run, destroy, or any -y option.
src/tc_migrate/commands/generate_cmd.py:25Terraform Preview Discloses Both Tencent Cloud SecretKeys
src/tc_migrate/config.py:261Cloud Credentials Are Duplicated into Plaintext Files Without Restrictive Permissions
src/tc_migrate/wizard.py:80SecretKeys Are Echoed During Interactive Entry and Accepted as Process Arguments
requirements.txt:4Python Dependencies Are Installed from Open-Ended Version Ranges Without Integrity Verification
The documented behavior claims broad cross-account migration and CCN-based interconnection, but the analysis indicates the implemented functionality only covers a narrower subset and may even reference a different networking model. In infrastructure tooling, this mismatch is dangerous because operators may trust the skill to perform secure migration steps or network isolation controls that are not actually implemented, leading to partial migrations, insecure connectivity, or unintended resource changes.
The guide presents tc-migrate destroy as a simple example with no warning that it can permanently delete migrated infrastructure and potentially sever connectivity. In an infrastructure-automation context, omission of a deletion warning materially increases the risk of accidental destructive execution and production outage.
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
# 添加 HashiCorp GPG key
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
# 添加仓库
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
# 添加 HashiCorp GPG key
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
# 添加仓库
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.
# 添加 HashiCorp GPG key
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
# 添加仓库
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.
# 添加 HashiCorp GPG key
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
# 添加仓库
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install terraform
---
The auto-generated configuration is saved after collecting account credentials, and the user-facing output explicitly says the secrets are also present in tc-migrate.yaml. Storing cloud API credentials in a general config file without a prominent pre-save warning or explicit consent materially increases the risk of credential leakage via version control, backups, file sharing, or overly broad filesystem access.
Code enumerates, copies, or searches environment variables for secrets. Bulk environment access can collect credentials unrelated to the skill's stated purpose.
cwd=str(tf_dir),
capture_output=capture_output,
text=True,
env={**os.environ, "TF_IN_AUTOMATION": "1"},
)
return result
The template renders account_a_secret_id, account_a_secret_key, account_b_secret_id, and account_b_secret_key directly into terraform.tfvars, and generate_tfvars() writes that content to disk in plaintext. In a cross-account cloud migration tool, these credentials are highly sensitive; if the file is read by other users, checked into source control, copied into logs/backups, or left on shared hosts, an attacker could gain broad control over both Tencent Cloud accounts.
The generated YAML embeds both source and destination cloud secret IDs and secret keys in plaintext, causing long-lived credentials to be persisted to disk. In a migration tool context this is especially dangerous because the file may be checked into source control, copied between systems, backed up, or read by other local users, exposing two Tencent Cloud accounts and enabling broad infrastructure compromise.
The README instructs users to create and populate an account.yaml file with source and destination cloud account keys, then run an automated cross-account migration, but it does not warn that these credentials are highly sensitive or that the operation can create, modify, or connect major network resources across accounts. In this context, missing security guidance increases the likelihood of credential mishandling, accidental over-privileging, or unintended infrastructure changes with broad blast radius.
The skill documents commands that read environment/configuration, create and modify files, and execute shell commands, but it does not declare any explicit tool scope such as permissions or allowed-tools. That makes the operational boundary ambiguous and can lead an agent runtime to grant broader capabilities than users expect, which is risky for a migration tool handling cloud credentials and infrastructure changes.
The README exposes a destructive destroy command with no adjacent warning, safeguards, or confirmation expectations. In the context of cross-account cloud migration, this can lead users or agents to delete infrastructure, networking, or state-backed resources with severe availability and recovery consequences.
The document shows SecretId and SecretKey being stored in account.yaml and propagated into generated files such as terraform.tfvars, but it does not warn users to secure, restrict, or exclude those files from version control. In an infrastructure-migration tool, exposed cloud credentials can enable full compromise of one or both Tencent Cloud accounts, including unauthorized provisioning, data access, and network changes.
This section documents commands that initialize Terraform, generate plans, and apply infrastructure changes across accounts, but it lacks a clear safety warning about cost, outage, access-control, and network-impact risks. In this context, operators may execute the workflow without understanding that it creates or modifies production networking and compute resources, increasing the chance of disruptive misconfiguration.
The documentation says under account A that '原有资源保持不变' while in the same section it states the tool performs 'CCN 跨账号关联申请(自动接受)'. Submitting and accepting a CCN cross-account association is an active change in the source account context, so the wording contradicts the described behavior.
The apply command performs live Terraform changes, and allowing -y/--yes to skip confirmation reduces a key safeguard against accidental infrastructure modification. In a cross-account migration tool managing VPC, CLB, NAT, CVM, and security groups, undocumented non-interactive apply can lead to unintended production-impacting changes.
The manifest describes a tool for cross-account resource migration, scanning, configuration generation, and Terraform deployment. This command reference additionally exposes destroy, which deletes all Terraform-managed resources; that is a powerful teardown capability not justified by the stated migration-focused purpose.
The document shows an account.yaml structure containing secret_id and secret_key for two cloud accounts but does not instruct users to protect the file, restrict permissions, or avoid committing it to version control. In a cross-account migration tool, these credentials are highly sensitive and could allow takeover or misuse of both source and target Tencent Cloud environments if exposed.
The entire installation guide is written only in Chinese, and there is no indication that users may choose another language or that the language restriction is required for a region-specific compliance purpose. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation.
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
# 安装 yum-utils
sudo yum install -y yum-utils
# 添加 HashiCorp 仓库
sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
# 安装 yum-utils
sudo yum install -y yum-utils
# 添加 HashiCorp 仓库
sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
# 安装 yum-utils
sudo yum install -y yum-utils
# 添加 HashiCorp 仓库
sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
# 安装 yum-utils
sudo yum install -y yum-utils
# 添加 HashiCorp 仓库
sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo