<!-- XE-0026 · api/tunnel: TCP tunnel authorization is a replayable static signature over the public lease hash (High) · testnet -->
*Markdown view of <https://bounty.xe.network/XE-0026>. The page is the record; this is the same page for reading.*

XE-0026 · Bounty

# api/tunnel: TCP tunnel authorization is a replayable static signature over the public lease hash (High)

Accepted
claimed High
[xe#48](https://github.com/xeprotocol/xe/issues/48)
filed 2026-10-25 11:12 UTC
by byfor8

Verdict
:   published when the fix ships

Tier
:   published when the fix ships

Claimed
:   High

Area
:   Node / API

Duplicate of
:   —

Tracked
:   internally

Updated
:   2026-11-10 11:38 UTC

Told
:   2026-11-10 00:15 UTC

### Patches

- [xe#122](https://github.com/xeprotocol/xe/pull/122) open by arturbarszcz78
  fix(api): prevent TCP tunnel signature replay, add timestamp/nonce binding, and enforce concurrency cap (#48, #94)

### History

- [61376](https://bounty.xe.network/log/61376) 2026-11-10 00:15 UTC reply.mirrored
- [61333](https://bounty.xe.network/log/61333) 2026-11-10 00:15 UTC reply.sent
- [10259](https://bounty.xe.network/log/10259) 2026-11-05 22:20 UTC proposal.adopted
- [10258](https://bounty.xe.network/log/10258) 2026-11-05 22:20 UTC ticket.award
- [10257](https://bounty.xe.network/log/10257) 2026-11-05 22:20 UTC proposal.rejected
- [6872](https://bounty.xe.network/log/6872) 2026-11-05 13:45 UTC proposal.created
- [1796](https://bounty.xe.network/log/1796) 2026-11-02 19:16 UTC proposal.created
- [1451](https://bounty.xe.network/log/1451) 2026-11-02 10:11 UTC note.added
- [716](https://bounty.xe.network/log/716) 2026-10-29 14:22 UTC note.added
- [715](https://bounty.xe.network/log/715) 2026-10-29 14:22 UTC ticket.facts area
- [615](https://bounty.xe.network/log/615) 2026-10-29 14:05 UTC github.labels
- [534](https://bounty.xe.network/log/534) 2026-10-29 14:04 UTC note.added

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

### Report

## Summary

The 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.

## Affected component

api/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.

## Impact

Anyone 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.

Suggested 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.

## PoC

Setup (from a fresh clone of xeprotocol/xe at the pin):

```
git clone https://github.com/xeprotocol/xe && cd xe
mkdir -p poc/harness
# save the two files below, then from poc/:
GOTOOLCHAIN=auto go mod tidy
GOTOOLCHAIN=auto go test -count=1 -v ./poc
```

go.mod for the poc module:

```
module poc

go 1.25.0

require github.com/xeprotocol/xe v0.0.0

replace github.com/xeprotocol/xe => ..
```

**Test file** (`poc/f11_test.go`):

```
package f11

import (
	"crypto/ed25519"
	"crypto/sha256"
	"encoding/hex"
	"fmt"
	"os"
	"testing"

	"github.com/xeprotocol/xe/core"
)

// TestPoC_F11 reproduces api/tunnel.go X-Signature semantics: the signed
// payload is the 32-byte lease hash only. The same signature verifies on
// every later check — there is no nonce, expiry, or request binding, so a
// captured header is a replayable bearer capability.
func TestPoC_F11(t *testing.T) {
	pass, detail := runF11()
	if pass {
		fmt.Println("PASS: F11 lease-hash signature verifies on replay with no nonce/expiry")
		fmt.Println(detail)
		return
	}
	fmt.Println("FAIL: F11 expected replay of ed25519(access_key, lease_hash) to keep verifying")
	fmt.Println(detail)
	os.Exit(0)
}

func runF11() (bool, string) {
	kp, err := core.GenerateKeyPair()
	if err != nil {
		return false, "keygen: " + err.Error()
	}
	// Stand-in for a public lease hash (GET /leases). Same 32-byte value
	// handleTunnelTCP passes to VerifyHexSignature.
	sum := sha256.Sum256([]byte("poc-f11-lease"))
	leaseHash := hex.EncodeToString(sum[:])
	hashBytes, err := core.DecodeHash(leaseHash)
	if err != nil {
		return false, "decode lease hash: " + err.Error()
	}

	sig := hex.EncodeToString(ed25519.Sign(kp.Private, hashBytes))

	first := core.VerifyHexSignature(kp.PubKeyHex(), sig, hashBytes)
	// Replay: same X-Signature, same lease hash, no challenge consumed.
	replay := core.VerifyHexSignature(kp.PubKeyHex(), sig, hashBytes)
	// Different payload (a second request / method bind) would need a new
	// signature if one existed. The tunnel path never binds one.
	other := sha256.Sum256([]byte("some other request"))
	cross := core.VerifyHexSignature(kp.PubKeyHex(), sig, other[:])

	detail := fmt.Sprintf(
		"lease_hash=%s
X-Signature=%s
"+
			"VerifyHexSignature first=%v replay=%v (both nil = bearer replay works)
"+
			"same sig over a different 32-byte payload err=%v (sig is bound only to the hash)",
		leaseHash, sig[:16]+"...", first, replay, cross,
	)
	ok := first == nil && replay == nil && cross != nil
	return ok, detail
}
```

**Run** (run 1 of 5 consecutive runs, 5/5 PASS, exit 0):

```
=== RUN   TestPoC_F11
PASS: F11 lease-hash signature verifies on replay with no nonce/expiry
lease_hash=eea96004b1ad0c5b49dd2ceed7d30182b4c60871d07f33780b04a7423274c21d
X-Signature=50aa1acaf26a688a...
VerifyHexSignature first=<nil> replay=<nil> (both nil = bearer replay works)
same sig over a different 32-byte payload err=signature verification failed (sig is bound only to the hash)
--- PASS: TestPoC_F11 (0.00s)
PASS
ok  	github.com/xeprotocol/xe-poc/f11	0.005s
```

## Fix suggestion

Bind the signature to a per-connection nonce plus method and path with a short validity window, and mark each challenge single use.

### 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-0026.
