<!-- XE-0076 · Lease SSH does not authenticate the server: no host key verification in SDK or CLI (MITM on job code, data and results) · testnet -->
*Markdown view of <https://bounty.xe.network/XE-0076>. The page is the record; this is the same page for reading.*

XE-0076 · Bounty

# Lease SSH does not authenticate the server: no host key verification in SDK or CLI (MITM on job code, data and results)

Accepted
claimed High
[xe#104](https://github.com/xeprotocol/xe/issues/104)
filed 2026-10-27 18:36 UTC
by BoomGone

Verdict
:   published when the fix ships

Tier
:   published when the fix ships

Claimed
:   High

Area
:   SDK / docs / web

Duplicate of
:   —

Tracked
:   internally

Updated
:   2026-11-10 11:38 UTC

Told
:   2026-11-10 00:15 UTC

### Patches

- [xe#140](https://github.com/xeprotocol/xe/pull/140) open by arturbarszcz78
  fix(cli): support SSH host key verification and custom known\_hosts in xe ssh (#104)

### History

- [61391](https://bounty.xe.network/log/61391) 2026-11-10 00:15 UTC reply.mirrored
- [61348](https://bounty.xe.network/log/61348) 2026-11-10 00:15 UTC reply.sent
- [10248](https://bounty.xe.network/log/10248) 2026-11-05 22:19 UTC proposal.adopted
- [10247](https://bounty.xe.network/log/10247) 2026-11-05 22:19 UTC ticket.award
- [10246](https://bounty.xe.network/log/10246) 2026-11-05 22:19 UTC proposal.rejected
- [6901](https://bounty.xe.network/log/6901) 2026-11-05 13:45 UTC proposal.created
- [1831](https://bounty.xe.network/log/1831) 2026-11-02 19:16 UTC proposal.created
- [1481](https://bounty.xe.network/log/1481) 2026-11-02 10:11 UTC note.added
- [781](https://bounty.xe.network/log/781) 2026-10-29 14:22 UTC note.added
- [780](https://bounty.xe.network/log/780) 2026-10-29 14:22 UTC ticket.facts area, claimed\_tier
- [602](https://bounty.xe.network/log/602) 2026-10-29 14:04 UTC github.labels
- [440](https://bounty.xe.network/log/440) 2026-10-29 14:04 UTC ticket.status triaging → accepted

[Full history](https://bounty.xe.network/log?ref=XE-0076) · [JSON](https://bounty.xe.network/v1/tickets/XE-0076) · [markdown](https://bounty.xe.network/XE-0076.md)

### 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 `hostVerifier` is 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:

1. The job's source code and all uploaded input files (confidentiality).
2. 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

1. Publish the gateway's SSH host public key (in `llms.txt`, docs, or a signed node field) and pin it via `hostVerifier` / `known_hosts` for the gateway hop in both SDK and CLI.
2. Return the leased VM's SSH host key fingerprint in the `LeaseRecord` so the inner hop can be verified too.
3. 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)

1. `grep -rniE 'hostVerifier|hostHash|known_hosts|fingerprint' src/` in the SDK returns nothing.
2. `src/jobs/ssh.ts:57-64` builds the client with no verifier.
3. `ssh2` README states the default is auto accept.
4. `cmd/xe/main.go:1204`/`:1211` disable 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

**XE desk**team2026-11-10 00:15 UTCgithub

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.
