An SSH client accepts any host key, so it cannot tell the server from an impostor

tx0/go:ssh-host-key-ignoredrecommendedwarningsecurity, cwe-322

What it finds

HostKeyCallback: ssh.InsecureIgnoreHostKey(): an SSH client that accepts any host key cannot tell the server it meant from one that sits in between, which then sees the password, the commands and their output. knownhosts.New checks keys against a known_hosts file; ssh.FixedHostKey against one known key.

Reported are calls of InsecureIgnoreHostKey of golang.org/x/crypto/ssh, resolved through the imports.

From the rule's source, ssh_host_key_ignored.rs.

Example from the rule's tests
package p import "golang.org/x/crypto/ssh" func config(user string, key ssh.PublicKey) []*ssh.ClientConfig {	return []*ssh.ClientConfig{		{User: user, HostKeyCallback: ssh.InsecureIgnoreHostKey()},tx0 reports: the SSH client accepts every host key		{User: user, HostKeyCallback: ssh.FixedHostKey(key)},	}}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/go:ssh-host-key-ignored" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/go:ssh-host-key-ignored] reason="..."

tx0 explain tx0/go:ssh-host-key-ignored shows the same in the terminal. Found a false positive? Report it.