T09 · Insecure Skill Coding Practices
Error
- Location
- ssh_exec.py:69
- Finding
- SSH Host-Key Verification Is Disabled by Default## Vulnerability Details **File Location**: `ssh_exec.py`, lines 69-75 **Vulnerability Type**: Improper SSH server authentication **Risk Level**: High ### Vulnerable Code ```python strict_host_key: bool = False, pty: bool = False, ) -> int: """Connect and execute a single command, returning the remote exit status.""" client = paramiko.SSHClient() if strict_host_key: client.load_system_host_keys() client.set_missing_host_key_policy(paramiko.RejectPolicy()) else: client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ``` ### Technical Analysis The `strict_host_key` option defaults to `False`. In this default mode, Paramiko's `AutoAddPolicy` automatically trusts a previously unknown SSH host key rather than rejecting it or asking the operator to verify its fingerprint. SSH host-key verification is the mechanism that authenticates the remote server. Disabling it makes the connection susceptible to a man-in-the-middle attack, particularly during the first connection or whenever no trusted key for the destination is available. Encryption alone does not prevent this attack because the client may establish the encrypted session directly with an attacker-controlled SSH server. ### Attack Path 1. A user invokes the Skill without the optional `--strict-host-key` argument. 2. The attacker obtains a network position that permits interception or redirection of traffic to the requested SSH destination, such as through DNS poisoning, routing manipulation, or a hostile local network. 3. The attacker presents an arbitrary SSH host key. 4. `AutoAddPolicy` accepts that key without validating it against a trusted fingerprint. 5. The client establishes a session with the attacker's server and submits the configured authentication and command data. 6. Depending on the authentication protocol and attacker setup, the attacker can impersonate the server, capture password credentials, ...[truncated 693 chars]
- Remediation
- ## Remediation Suggestions - Make strict host-key verification the default behavior. - Load system or application-specific `known_hosts` entries and use `paramiko.RejectPolicy()` for unknown keys. - Support explicit host-key or fingerprint pinning for automated environments. - If an insecure compatibility mode is indispensable, require an explicit argument such as `--insecure-accept-unknown-host-key` and emit a prominent warning. - Do not silently modify trusted host-key data during normal execution. - Document a secure onboarding process through which operators verify a server fingerprint over an independent trusted channel before connecting. - Add tests confirming that unknown and changed host keys are rejected by default.
