T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/healthcheck.sh:6
- Finding
- SSH Host-Key Verification Is Disabled## Vulnerability Details **File Location**: `scripts/healthcheck.sh`, line 6 **Vulnerability Type**: Improper SSH server authentication **Risk Level**: Medium ### Vulnerable Code ```bash ssh -i $KEY -o StrictHostKeyChecking=no $USER@$HOST << EOF ``` ### Technical Analysis The script explicitly sets `StrictHostKeyChecking=no`. This causes SSH to accept an unknown or changed server host key without requiring validation by the operator. SSH host-key verification establishes that the remote endpoint is the intended server. Disabling it allows a system controlling DNS resolution, network routing, or a network gateway to impersonate the target host. Although SSH public-key authentication does not directly disclose the private key, the client can authenticate to or interact with an unintended endpoint without warning. The behavior is not necessary for health auditing. A health-check tool can use the normal SSH trust model, a pre-provisioned `known_hosts` file, or carefully controlled trust-on-first-use behavior. ### Attack Path 1. A user invokes the health-check script for a remote VPS. 2. An attacker interferes with DNS resolution or network routing for the specified host. 3. The attacker presents an SSH host key that is not associated with the legitimate VPS. 4. `StrictHostKeyChecking=no` suppresses the host-identity validation failure. 5. The script connects to the attacker-controlled endpoint and runs the diagnostic command sequence against the wrong server. ### Impact Assessment An attacker can impersonate the audited server and cause the client to establish an SSH connection to an unintended host. This undermines the integrity and confidentiality of the audit session and can produce falsified health-check results. The vulnerability does not, by itself, reveal the contents of the client's private key or grant access to the legitimate server.
- Remediation
- ## Remediation Suggestions - Remove `-o StrictHostKeyChecking=no`. - Use `StrictHostKeyChecking=yes` for pre-provisioned infrastructure. - Maintain a dedicated `known_hosts` file containing independently verified host keys. - If trust on first use is operationally required, use `StrictHostKeyChecking=accept-new`; this still rejects changed keys. - Consider specifying a dedicated known-hosts database: ```bash ssh \ -o StrictHostKeyChecking=yes \ -o UserKnownHostsFile="$HOME/.ssh/known_hosts" \ -i "$KEY" \ "$USER@$HOST" ``` - Document a secure process for verifying server fingerprints before the first audit.
