{"id":"XE-0026","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"48","source_url":"https://github.com/xeprotocol/xe/issues/48","reporter_id":13,"title":"api/tunnel: TCP tunnel authorization is a replayable static signature over the public lease hash (High)","area":"node-api","claimed_tier":"high","assessed_tier":null,"verdict":null,"duplicate_of":null,"tracked":true,"internal_ref":"","internal_url":null,"status":"accepted","closed_reason":null,"github_state":"open","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-10-29T13:57:16.594182+00:00","updated_at":"2026-11-10T11:38:16.208350+00:00","source_created_at":"2026-10-25T11:12:15+00:00","told_at":"2026-11-10T00:15:23+00:00","status_changed_at":"2026-10-29T14:04:12.101682+00:00","url":"https://bounty.xe.network/XE-0026","body":"## Summary\nThe HTTP TCP tunnel endpoint authorizes with an ed25519 signature over the 32 byte lease hash and nothing else. The lease hash is public via the leases API, there is no nonce, timestamp, method or target binding, and the check runs on every request with no single-use state. One observed X-Signature header value is a bearer capability for the lease's entire accepted lifetime: it can be replayed indefinitely, and the hijacked connection has no deadline while the API's 60 second write timeout no longer applies after hijack.\n\n## Affected component\napi/tunnel.go, signature check at lines 30 to 47 (VerifyHexSignature over DecodeHash(leaseHash) only), hijack at line 62, no connection cap on this path (the SSH gateway caps at 100), at commit 978785929bc17a2f4ab30c383e5fc9cf4d634512.\n\n## Impact\nAnyone who captures one tunnel request header (provider access log, reverse proxy, shared host) keeps VM TCP access for the life of the lease without ever holding the access private key. SSH login still requires the guest key, so this is not a remote shell by itself, but the TCP reach plus the unbounded hijacked sockets on the provider are a real escalation from passive observation.\n\nSuggested severity: High (replay attack; VM access with the wrong key, both named in the program's High tier). Distinct from issue #4 finding 2, which covers the P2P peer check and post-expiry access; this report is about the token construction on the HTTP path. Confirmed by read-only source review.\n\n## PoC\n\nSetup (from a fresh clone of xeprotocol/xe at the pin):\n\n```\ngit clone https://github.com/xeprotocol/xe && cd xe\nmkdir -p poc/harness\n# save the two files below, then from poc/:\nGOTOOLCHAIN=auto go mod tidy\nGOTOOLCHAIN=auto go test -count=1 -v ./poc\n```\n\ngo.mod for the poc module:\n\n```\nmodule poc\n\ngo 1.25.0\n\nrequire github.com/xeprotocol/xe v0.0.0\n\nreplace github.com/xeprotocol/xe => ..\n```\n\n**Test file** (`poc/f11_test.go`):\n\n```go\npackage f11\n\nimport (\n\t\"crypto/ed25519\"\n\t\"crypto/sha256\"\n\t\"encoding/hex\"\n\t\"fmt\"\n\t\"os\"\n\t\"testing\"\n\n\t\"github.com/xeprotocol/xe/core\"\n)\n\n// TestPoC_F11 reproduces api/tunnel.go X-Signature semantics: the signed\n// payload is the 32-byte lease hash only. The same signature verifies on\n// every later check — there is no nonce, expiry, or request binding, so a\n// captured header is a replayable bearer capability.\nfunc TestPoC_F11(t *testing.T) {\n\tpass, detail := runF11()\n\tif pass {\n\t\tfmt.Println(\"PASS: F11 lease-hash signature verifies on replay with no nonce/expiry\")\n\t\tfmt.Println(detail)\n\t\treturn\n\t}\n\tfmt.Println(\"FAIL: F11 expected replay of ed25519(access_key, lease_hash) to keep verifying\")\n\tfmt.Println(detail)\n\tos.Exit(0)\n}\n\nfunc runF11() (bool, string) {\n\tkp, err := core.GenerateKeyPair()\n\tif err != nil {\n\t\treturn false, \"keygen: \" + err.Error()\n\t}\n\t// Stand-in for a public lease hash (GET /leases). Same 32-byte value\n\t// handleTunnelTCP passes to VerifyHexSignature.\n\tsum := sha256.Sum256([]byte(\"poc-f11-lease\"))\n\tleaseHash := hex.EncodeToString(sum[:])\n\thashBytes, err := core.DecodeHash(leaseHash)\n\tif err != nil {\n\t\treturn false, \"decode lease hash: \" + err.Error()\n\t}\n\n\tsig := hex.EncodeToString(ed25519.Sign(kp.Private, hashBytes))\n\n\tfirst := core.VerifyHexSignature(kp.PubKeyHex(), sig, hashBytes)\n\t// Replay: same X-Signature, same lease hash, no challenge consumed.\n\treplay := core.VerifyHexSignature(kp.PubKeyHex(), sig, hashBytes)\n\t// Different payload (a second request / method bind) would need a new\n\t// signature if one existed. The tunnel path never binds one.\n\tother := sha256.Sum256([]byte(\"some other request\"))\n\tcross := core.VerifyHexSignature(kp.PubKeyHex(), sig, other[:])\n\n\tdetail := fmt.Sprintf(\n\t\t\"lease_hash=%s\nX-Signature=%s\n\"+\n\t\t\t\"VerifyHexSignature first=%v replay=%v (both nil = bearer replay works)\n\"+\n\t\t\t\"same sig over a different 32-byte payload err=%v (sig is bound only to the hash)\",\n\t\tleaseHash, sig[:16]+\"...\", first, replay, cross,\n\t)\n\tok := first == nil && replay == nil && cross != nil\n\treturn ok, detail\n}\n```\n\n**Run** (run 1 of 5 consecutive runs, 5/5 PASS, exit 0):\n\n```\n=== RUN   TestPoC_F11\nPASS: F11 lease-hash signature verifies on replay with no nonce/expiry\nlease_hash=eea96004b1ad0c5b49dd2ceed7d30182b4c60871d07f33780b04a7423274c21d\nX-Signature=50aa1acaf26a688a...\nVerifyHexSignature first=<nil> replay=<nil> (both nil = bearer replay works)\nsame sig over a different 32-byte payload err=signature verification failed (sig is bound only to the hash)\n--- PASS: TestPoC_F11 (0.00s)\nPASS\nok  \tgithub.com/xeprotocol/xe-poc/f11\t0.005s\n```\n\n## Fix suggestion\nBind the signature to a per-connection nonce plus method and path with a short validity window, and mark each challenge single use.","patch_refs":[{"id":142,"repo":"xeprotocol/xe","kind":"pr","ref":"122","title":"fix(api): prevent TCP tunnel signature replay, add timestamp/nonce binding, and enforce concurrency cap (#48, #94)","url":"https://github.com/xeprotocol/xe/pull/122","note":"","state":"open","author":"arturbarszcz78","added_by":"desk","created_at":"2026-10-29T13:57:30.091343+00:00"}],"thread":[{"id":1553,"source":"github","source_ref":"6755086832","author":"XE desk","team":true,"body":"Read and accepted. It is tracked internally and the fix will land in a public PR; this issue is\nupdated when it does, and the tier and award follow the fix. The desk entry is https://bounty.xe.network/XE-0026.","created_at":"2026-11-10T00:15:23+00:00"}]}