{"id":"XE-8592","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":1727,"title":"`xe ssh` treats a 404 lease as present: `client.getJSON` ignores HTTP status, so a missing lease still invokes OpenSSH against the public gateway","area":"sdk-docs-web","claimed_tier":"medium","assessed_tier":null,"verdict":"duplicate","duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":"","status":"closed","closed_reason":"duplicate","github_state":"","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-11T23:53:37.702327+00:00","updated_at":"2026-11-17T09:42:07.586797+00:00","source_created_at":null,"told_at":"2026-11-17T09:42:07.607706+00:00","status_changed_at":"2026-11-17T09:42:07.593242+00:00","url":"https://bounty.xe.network/XE-8592","body":"## Summary\r\n\r\n`client.getJSON` always decodes the response body and returns `(map, nil)`, even when the node answers `404` / `4xx` / `5xx`. `GetLease` is a thin wrapper around it:\r\n\r\n```go\r\nfunc (c *Client) GetLease(hash string) (map[string]interface{}, error) {\r\n\treturn c.getJSON(fmt.Sprintf(\"%s/leases/%s\", c.BaseURL, hash))\r\n}\r\n```\r\n\r\nAgainst a missing lease the live node returns `404 {\"error\":\"lease not found\"}`. `GetLease` therefore returns `map[error:lease not found], err=nil` — a non-nil map.\r\n\r\n`cmdSSH` only treats a **nil** lease as missing:\r\n\r\n```go\r\nlease, _ := c.GetLease(leaseHash)\r\nif lease == nil {\r\n    fatal(\"lease not found: %s\", leaseHash)\r\n}\r\nif settled, _ := lease[\"settled\"].(bool); settled { ... }\r\n// then builds ProxyCommand and exec.Command(\"ssh\", ...)\r\n```\r\n\r\nSo `xe ssh <any-64-hex-that-is-not-a-lease>` never prints \"lease not found\". It proceeds to `exec` the system `ssh` with `ProxyCommand=… <hash>@ldn.test.network` (or `XE_SSH_HOST`). Contrast `xe lease status`, which correctly checks `lease[\"error\"]` and fatals.\r\n\r\n## Steps to reproduce\r\n\r\nBuild `xe` at `89a542e`. Use any wallet path that has (or create) a PEM at `<wallet-without-.seed>.lease_key_openssh` so the \"no SSH key\" path is not hit — a dummy PEM is enough because we only need to prove `ssh` is invoked:\r\n\r\n```bash\r\nXE_WALLET=/path/to/w.seed\r\nprintf '%s\\n' '-----BEGIN OPENSSH PRIVATE KEY-----' 'x' '-----END OPENSSH PRIVATE KEY-----' \\\r\n  > \"$(dirname \"$XE_WALLET\")/$(basename \"$XE_WALLET\" .seed).lease_key_openssh\"\r\n\r\n# Prove OpenSSH is reached for a lease that does not exist:\r\ncat > /tmp/binfake/ssh <<'SH'\r\n#!/bin/bash\r\necho \"FAKE_SSH_INVOKED args=$*\" >&2\r\nexit 42\r\nSH\r\nchmod +x /tmp/binfake/ssh\r\nPATH=/tmp/binfake:$PATH XE_WALLET=$XE_WALLET ./xe ssh aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n# → prints FAKE_SSH_INVOKED … aaaa…@ldn.test.network … root@vm ; exit 42\r\n\r\n# Control: the sibling command correctly rejects the same hash\r\n./xe lease status aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n# → error: lease not found: aaaa…\r\n```\r\n\r\nRead-only confirmation that `GetLease` itself is status-blind (no SSH):\r\n\r\n```go\r\nc := client.New(\"https://ldn.core.test.network\")\r\nm, err := c.GetLease(\"0000000000000000000000000000000000000000000000000000000000000000\")\r\n// err == nil, m == map[error:lease not found]\r\n```\r\n\r\n## Evidence\r\n\r\nObserved 12 Nov 2026 06:50 WIB against `https://ldn.core.test.network` with a throwaway wallet and a PATH-shadowed `ssh`:\r\n\r\n```\r\nFAKE_SSH_INVOKED args=-o ProxyCommand=ssh -p 2222 -i …/w1.lease_key_openssh -W %h:%p\r\n  -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR\r\n  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa@ldn.test.network\r\n  -i …/w1.lease_key_openssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null\r\n  -o LogLevel=ERROR root@vm\r\nexit:42\r\n```\r\n\r\n`GetLease` on a zero hash contemporaneously returned `err=<nil> map=map[error:lease not found]`. `xe lease status` on the same hash exited 1 with `lease not found`.\r\n\r\nNo real SSH session to a VM was opened; the fake binary exited immediately. No lease was created, no funds moved.\r\n\r\n## Expected vs actual\r\n\r\n- **Expected:** a missing lease → clear `lease not found` (as `lease status` already does); no `ssh` process; HTTP non-2xx from `GetLease`/`getJSON` returned as an error.\r\n- **Actual:** 404 is decoded as a successful map; `xe ssh` skips the nil check and execs OpenSSH toward the public gateway with the caller-supplied hash as the gateway username.\r\n\r\n## Impact\r\n\r\n- Operators get no \"lease not found\" signal and instead open outbound SSH to `XE_SSH_HOST` (default `ldn.test.network:2222`) with a fabricated lease identity.\r\n- Composes with the already-reported ProxyCommand injection class (XE-2814): the hash reaches the shell-interpolated `ProxyCommand` without an existence check.\r\n- Same `getJSON` blindness also makes `GetCertificate` return `map[error:…]` with `err=nil` (cmdLease currently papers over that by testing `hash == nil`).\r\n\r\n## Suggested fix\r\n\r\nMake `getJSON` (and every status-blind getter) return an error on non-2xx, matching `GetReputation` / `GetVM`. In `cmdSSH`, also reject maps that carry an `error` field or lack expected lease fields before building `ProxyCommand`.\r\n\r\n## Dedup\r\n\r\nSearched all **1,458 public** tickets (refreshed 12 Nov 2026 06:42 WIB). Nearby but **not** the same impact:\r\n\r\n- XE-8572 — Go client ignores HTTP status in **GetPending / GetProviders / GetBalances** (false empty results). Does not mention `getJSON`, `GetLease`, or `xe ssh`.\r\n- XE-0121 / XE-0625 / XE-0744 — GetChain / other getters status-blindness and nil handling; closed or scoped to send/prev=0.\r\n- XE-2814 — shell injection via lease hash in ProxyCommand (assumes the command runs); this report is that the command runs **at all** for a non-existent lease.\r\n- XE-0076 / XE-2351 — StrictHostKeyChecking=no (host-key MITM), not existence checks.\r\n\r\n**Caveat:** private tickets cannot be searched.","patch_refs":[],"thread":[{"id":9876,"source":"desk","source_ref":"reply:8314","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the\nfirst verifiable submission, so this one closes as a duplicate. If you believe it is a different\nbug, file a new report that links https://bounty.xe.network/XE-8592 and says what differs; it is read like any other.","created_at":"2026-11-17T09:42:07.586797+00:00"}]}