T09 · Insecure Skill Coding Practices
- Location
scripts/create_ecs_and_setup_devkit.py:199- Finding
Automatic SSH Host-Key Acceptance Enables Credential Interception
- Content
View full analysis
Vulnerability Details
File Location:
scripts/create_ecs_and_setup_devkit.py, lines 199–202 and 440–447
Vulnerability Type: Missing SSH server identity verification
Risk Level: HighVulnerable Code
python def ssh_install_devkit(eip, password, devkit_url, install_path="", install_port="", wait=False): import paramiko ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) try: ssh.connect(eip, port=22, username="root", password=password, timeout=30)The status connection repeats the same insecure trust policy:
python ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) try: ssh.connect(eip, port=22, username="root", password=password, timeout=15) except Exception as e: print(f"ERROR: SSH connection to {eip} failed: {e}", file=sys.stderr) del password sys.exit(1)Technical Analysis
paramiko.AutoAddPolicy()automatically accepts any SSH host key presented by an unknown endpoint. The code does not load a trusted host key, compare a fingerprint obtained through Huawei Cloud, or ask the user to verify the server identity.Password authentication occurs immediately after accepting the unverified key. The credential is the generated ECS root password recovered from KMS, so accepting a hostile SSH endpoint exposes a high-privilege secret rather than merely establishing an unauthenticated monitoring connection.
This crosses the network trust boundary between the local deployment agent and the intended ECS. An endpoint that is reachable at the supplied EIP is implicitly treated as the newly created ECS without cryptographic identity verification.
Attack Path
- The user or agent invokes the
installorstatussubcommand with the intended ECS EIP. - A network-positioned attacker redirects, intercepts, or otherwise causes the SSH connection to reach an attacke ...[truncated 1159 chars]
- The user or agent invokes the
- Remediation
View remediation
Remediation Suggestions
- Replace
AutoAddPolicywithparamiko.RejectPolicy()for both installation and status connections. - Obtain the new ECS host-key fingerprint through a trusted channel, such as authenticated cloud-init output, the cloud console, or a provider API.
- Create a dedicated known-hosts file containing only the expected ECS address and host key, then load it with
SSHClient.load_host_keys(). - Compare the server key or fingerprint before sending the password and abort on missing or mismatched identity data.
- Do not rely on a previously cached key unless its provenance and association with the current ECS instance are verified.
- Prefer short-lived SSH certificates or a freshly generated deployment key over reusable root-password authentication where supported.
- Apply the same host-identity enforcement to every connection path, including
ssh_install_devkit()and_ssh_connect_with_kms().
- Replace
