Why it matters
A machine in the network path can impersonate the server and read the session.
How to fix it
Verify the host key with ssh.FixedHostKey or a knownhosts callback (golang.org/x/crypto/ssh/knownhosts).
Example
The rule's own test fixtures, verbatim: the test suite requires the rule to report the first and not the second.
package fixture
import "golang.org/x/crypto/ssh"
func config(user string) *ssh.ClientConfig {
return &ssh.ClientConfig{User: user, HostKeyCallback: ssh.InsecureIgnoreHostKey()}
}package fixture
import "golang.org/x/crypto/ssh"
func config(user string, hostKey ssh.PublicKey) *ssh.ClientConfig {
return &ssh.ClientConfig{User: user, HostKeyCallback: ssh.FixedHostKey(hostKey)}
}What TrustIvan reads
Runs on repository scans of Go source once static analysis is turned on (SAST_RULES and the separately built analyzer image); it is off by default.
Weakness classes and references
Related checks
- TLS old minimum version (Go)
GoSeverity: Medium
trustivan-go-tls-old-minimum-version - HTTP server without timeouts (Go)
GoSeverity: Medium
trustivan-go-http-server-without-timeouts - Math rand secret (Go)
GoSeverity: Medium
trustivan-go-math-rand-secret - World writable file mode (Go)
GoSeverity: Medium
trustivan-go-world-writable-file-mode - Weak cipher (Go)
GoSeverity: High
trustivan-go-weak-cipher - Zip slip (Go)
GoSeverity: High
trustivan-go-zip-slip
Terms: SAST (static application security testing), Taint analysis, CWE (Common Weakness Enumeration), OWASP Top 10
All static analysis (SAST) checks · The whole catalogue · How this works in TrustIvan · Documentation