OSV 1.4.0 · github-reviewed · 修改于 2026-05-16 01:17
发布时间
2026-05-16 01:17
GitHub 审查时间
2026-05-16 01:17
NVD 发布时间
—
源文件
advisories/github-reviewed/2026/05/GHSA-mxg3-432p-mr72/GHSA-mxg3-432p-mr72.json
The --tunnel / -t flag opens an outbound SSH connection to localhost.run:22 with HostKeyCallback: ssh.InsecureIgnoreHostKey(). The Go documentation for that function states verbatim: "It should not be used for production code." With the callback disabled the client accepts any host key the server presents, so an attacker who can intercept the operator's TCP connection to localhost.run:22 (any router on the path, malicious local network, ARP/DNS spoof on the operator's LAN, BGP hijack, malicious VPN) can present their own SSH host key, terminate the SSH session locally, and proxy onward — sitting transparently in the middle of the tunnel.
Because localhost.run does TLS termination at their end, the HTTP traffic on the SSH leg is plaintext, so the on-path attacker reads and rewrites every request and response in cleartext. The goshs operator gets no warning; the public URL works normally.
File: tunnel/tunnel.go
func Start(localIP string, localPort int) (*Tunnel, error) {
config := &ssh.ClientConfig{
User: "nokey",
Auth: []ssh.AuthMethod{ssh.Password("")},
HostKeyCallback: ssh.InsecureIgnoreHostKey(), // accepts any server key
Timeout: 10 * time.Second,
BannerCallback: func(banner string) error { return nil },
}
client, err := ssh.Dial("tcp", "localhost.run:22", config)
...
}
There is no fallback verification — no ssh.FixedHostKey, no known_hosts read, no TOFU pin. Every invocation of goshs --tunnel is equally vulnerable.
goshs --tunnel. tunnel.Start() opens an SSH client to localhost.run:22 with InsecureIgnoreHostKey().arpspoof + DNS spoof on the operator's LAN) intercepts the outbound TCP connection to localhost.run:22 and answers with their own SSH server.HostKeyCallback returns nil unconditionally. Handshake completes; the client believes it is talking to localhost.run.localhost.run:22, forwarding the URL capture so Start() reads back the genuine https://*.lhr.life line and returns successfully. The operator sees the public URL printed to stdout exactly as expected.Authorization value sent by every visitor.Set-Cookie attributes.Authorization, file contents, share-link tokens, the ?goshs-info JSON dump).<script> into HTML responses, swap offered binaries for backdoored ones.goshs --tunnel / goshs -t.localhost.run:22 (LAN MITM, malicious Wi-Fi, hostile ISP/VPN, BGP hijack, or DNS spoofing combined with an attacker-controlled SSH endpoint).ssh.InsecureIgnoreHostKey() has been replaced with a Trust-On-First-Use (TOFU) host key callback backed by ~/.config/goshs/known_hosts.
Behaviour after the fix:
On first connection: goshs accepts the host key presented by localhost.run, writes it to ~/.config/goshs/known_hosts (mode 0600), and prints two warning lines:
WARN tunnel: pinned new host key for localhost.run:22 (SHA256:<fingerprint>) in ~/.config/goshs/known_hosts
WARN tunnel: verify with: ssh-keyscan localhost.run 2>/dev/null | ssh-keygen -l -f -
The operator should compare the printed fingerprint against the ssh-keyscan output to confirm no MITM occurred on that first connection.
On subsequent connections: the stored key is loaded via golang.org/x/crypto/ssh/knownhosts and the presented key is verified against it. A mismatch returns a typed HostKeyMismatchError and goshs exits immediately with:
FATAL tunnel: ssh: host key mismatch for localhost.run:22 — possible MITM attack.
If localhost.run legitimately rotated its key, delete ~/.config/goshs/known_hosts and reconnect
Files changed:
| File | Change |
|---|---|
config/config.go | Added Dir() — creates and returns ~/.config/goshs (mode 0700) |
main.go | Calls config.Dir() on every startup to ensure the directory exists |
tunnel/tunnel.go | Replaced InsecureIgnoreHostKey() with buildTOFUCallback(knownHostsFile); added exported HostKeyMismatchError type |
httpserver/server.go | Resolves ~/.config/goshs/known_hosts via config.Dir(), passes it to tunnel.Start(); fatal-exits on HostKeyMismatchError |
Implementation uses only already-vendored dependencies (golang.org/x/crypto/ssh/knownhosts is part of the existing golang.org/x/crypto direct dependency — no new modules added).