Lease SSH does not authenticate the server: no host key verification in SDK or CLI (MITM on job code, data and results)
Report
Summary
When the TypeScript SDK (@xeprotocol/sdk, jobs entry) runs a job on a leased machine it opens two SSH hops, to the network gateway and then to the machine itself, using the ssh2 library, and it never verifies either server's host key. The ssh2 client is built with no hostVerifier, and that library's documented default is to auto accept whatever host key the server presents. The Go CLI does the same thing on purpose, with StrictHostKeyChecking=no and UserKnownHostsFile=/dev/null.
The effect is the SSH equivalent of disabling TLS certificate verification, on the channel that carries the caller's job code, input files and results.
Evidence
SDK src/jobs/ssh.ts, the only place an ssh2 client is built:
function connect(options) {
return new Promise((resolve, reject) => {
const c = new Client()
c.once('ready', () => resolve(c))
.once('error', reject)
.connect({ readyTimeout: 30_000, keepaliveInterval: 10_000, ...options })
})
}
openMachineSession (ssh.ts:79) calls this for both hops and passes only host, port, username, privateKey/sock. No hostVerifier, no hostHash. A grep of the SDK for hostVerifier|hostHash|known_hosts|fingerprint returns nothing, and there is no host key field in the lease, provider or type models, so a caller cannot supply one either.
The ssh2 default, from its own README:
hostVerifier ... Default: (auto-accept if
hostVerifieris not set)
ssh2 is a hard dependency ("ssh2": "^1.17.0"). The public entry is runJob (src/jobs/index.ts), used by every examples/jobs/ sample; the gateway defaults to the fixed ldn.test.network:2222 resolved by DNS. runJob uploads the caller's files to /root/job, runs a command as root, and reads stdout/stderr/output files back over that session.
CLI parity, cmd/xe/main.go:1204 and :1211:
proxyCmd := fmt.Sprintf("ssh ... -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ...")
...
"-o", "UserKnownHostsFile=/dev/null",
Impact
An attacker in an active man in the middle position on the path to the gateway (rogue or shared Wi-Fi/LAN with ARP spoofing, DNS spoofing of ldn.test.network, a compromised upstream, a BGP hijack) can present their own host key. The client auto accepts it and completes the handshake against the impostor. Authentication runs client to server, not server to client, so the lease access key does not detect the impostor. The attacker then obtains, over a channel the caller believes is private:
- The job's source code and all uploaded input files (confidentiality).
- Full control of the returned stdout, stderr, exit code and output files, handed back to the caller as genuine results (integrity, silent).
The attacker can relay on to the real gateway so the job still looks normal.
Honest scope
- The job uses a fresh per job key for auth and SSH public key auth never sends the private key, so this is not key theft; the damage is confidentiality and integrity of the job within an attacker controlled session.
- The outer gateway hop is the crux; the inner hop runs through the gateway's forwarded channel, so the inner hop being unverified is defence in depth gone rather than a second independent hole.
- This looks intentional in the current code, so it may be a known and accepted testnet tradeoff (ephemeral VMs, no host key PKI yet). Raising it because no issue covers it and because the sibling weakness #48 (lease tunnel authorization is a replayable static signature, High) shows this layer is in scope and graded seriously. #48 is a client authentication weakness; this is the absence of server authentication. Together the lease SSH channel authenticates neither end soundly. #67 is a separate gateway DoS.
Suggested fix
- Publish the gateway's SSH host public key (in
llms.txt, docs, or a signed node field) and pin it viahostVerifier/known_hostsfor the gateway hop in both SDK and CLI. - Return the leased VM's SSH host key fingerprint in the
LeaseRecordso the inner hop can be verified too. - Until then, document that the lease SSH channel is not protected against an active network attacker, so testers do not send sensitive job code or data over it.
Repro (code analysis, no funds needed)
grep -rniE 'hostVerifier|hostHash|known_hosts|fingerprint' src/in the SDK returns nothing.src/jobs/ssh.ts:57-64builds the client with no verifier.ssh2README states the default is auto accept.cmd/xe/main.go:1204/:1211disable host key checking in the CLI.
A live demonstration needs a funded lease (XUSD, not obtainable by testers yet) plus an MITM harness, so this is filed as code analysis, the same basis as #81.
Payout address
6591eab453dbd93b27e2cd674712f94b42d9e7e4d52980b966fa6da4ccd832dc
Thread
Read and accepted. It is tracked internally and the fix will land in a public PR; this issue is updated when it does, and the tier and award follow the fix. The desk entry is https://bounty.xe.network/XE-0076.