{"id":"XE-1134","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"291","source_url":"https://github.com/xeprotocol/xe/issues/291","reporter_id":314,"title":"[HIGH] net: Gossip.Subscribe requires len(b.Signature) == 128 and silently drops 100% of multisig blocks across the network","area":"p2p-sync","claimed_tier":"high","assessed_tier":null,"verdict":"duplicate","duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":"","status":"closed","closed_reason":"duplicate","github_state":"closed","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-07T16:36:47.150676+00:00","updated_at":"2026-11-14T22:55:19.041596+00:00","source_created_at":"2026-11-07T16:35:54+00:00","told_at":"2026-11-14T22:53:24+00:00","status_changed_at":"2026-11-08T20:32:07.337715+00:00","url":"https://bounty.xe.network/XE-1134","body":"## Summary\n\nEvery multisig block in XE (`multisig_open`, `multisig_update`, and any `send`, `receive`, `lease`, `lease_accept`, `lease_settle`, `lease_cancel`, `lease_force_settle`, `lease_renew`, `burn`, or `mint` signed by a multisig account) carries an empty single-key `Signature` field (`b.Signature == \"\"`) and stores its credentials in `b.Signatures []core.BlockSignature`.\n\nWhile the GossipSub topic validator `blockValidator` (`net/gossip_validate.go:77`) was updated to accept multisig blocks (`if len(b.Signature) != 128 && len(b.Signatures) == 0`), the subscriber loop `Gossip.Subscribe` (`net/gossip.go:150`) still enforces `len(b.Signature) != 128`:\n\n```go\nb := bm.Block\nif len(b.Hash) != 64 || len(b.Signature) != 128 || len(b.Account) != 64 {\n    continue\n}\n```\n\nBecause `len(b.Signature) == 0` on every valid multisig block (and `core.ValidatePubKeyDeclaration` / `core.VerifyBlock` treat `len(b.Signatures) > 0` as the multisig credential path), `Gossip.Subscribe` silently drops **100% of multisig blocks** on every subscribing node in the network immediately after `blockValidator` accepts and forwards them across the GossipSub mesh.\n\nIn addition, `blockValidator` (`net/gossip_validate.go:77`) only checks `len(b.Signature) != 128 && len(b.Signatures) == 0` without enforcing mutual exclusion between `b.Signature` and `b.Signatures`, without bounding `len(b.Signatures)` to the 256-key canonical keyset cap (`unmarshalKeysetCanonical` in `core/encoding.go:567`), and without validating that each `core.BlockSignature` entry has a 64-character hex `PublicKey`, a 128-character hex `Sig`, and unique signers.\n\n## Affected Code\n\n- `net/gossip.go` (`Gossip.Subscribe`, lines 149–152):\n  ```go\n  b := bm.Block\n  if len(b.Hash) != 64 || len(b.Signature) != 128 || len(b.Account) != 64 {\n      continue\n  }\n  ```\n- `net/gossip_validate.go` (`blockValidator`, lines 73–79):\n  ```go\n  if !isHex64(b.Hash) || !isHex64(b.Account) {\n      return pubsub.ValidationReject\n  }\n\n  if len(b.Signature) != 128 && len(b.Signatures) == 0 {\n      return pubsub.ValidationReject\n  }\n  ```\n- `node/node.go` (`Node.handleIncoming`, lines 570, 705–739):\n  `n.handleIncoming(gossip.Subscribe(ctx))` is the sole entry point for live gossip block ingestion, provider lease auto-acceptance (`n.autoAcceptLease(b)` at line 721), and consumer VM credential scrubbing on `lease_settle` (lines 729–737).\n\n## Root Cause & Impact\n\n1. **100% Gossip Drop of All Multisig Blocks**:\n   - When a node accepts a multisig block via `SubmitBlock` (`node/node.go:1282`) and calls `n.Gossip.Publish(n.ctx, b)`, GossipSub's `blockValidator` returns `pubsub.ValidationAccept`, but every peer's `Gossip.Subscribe` loop hits `len(b.Signature) != 128` (`0 != 128`) and executes `continue`.\n   - No peer or representative ever receives any multisig block over the `xe/blocks` gossip topic.\n\n2. **Provider `autoAcceptLease` & VM Provisioning Never Trigger for Multisig Consumers (Escrow Lockup)**:\n   - In `node/node.go:721`, provider auto-acceptance (`n.autoAcceptLease(b)`) is triggered **exclusively** inside `handleIncoming(gossip.Subscribe(ctx))` and is never invoked when blocks arrive later via `/xe/sync/1.0.0` (`Ledger.AddSyncedBlock`).\n   - Consequently, any `lease` block submitted by a multisig consumer account is dropped by `Gossip.Subscribe` on the provider node, so the provider never auto-accepts the lease or provisions the VM, leaving the multisig consumer's XUSD locked in escrow until expiration.\n   - Similarly, a `lease_settle` block from a multisig provider never reaches `handleIncoming` (`node/node.go:729`) on the consumer node to mark the VM `\"stopped\"` and scrub cached credentials.\n\n3. **Delayed/Suppressed Fork Detection on Conflicting Multisig Blocks**:\n   - If two conflicting multisig blocks at the same `(Account, Previous)` are submitted to different nodes, neither block is delivered over `xe/blocks` gossip. During `/xe/sync/1.0.0`, `findMissingBlocksPaginated` (`net/sync.go:714`) treats the peer's divergent frontier as unrecognized rather than staging a conflict until multiple consecutive sync rejections elapse.\n\n4. **Unvalidated `b.Signatures` Entries & Hybrid `Signature`+`Signatures` Bypass in `blockValidator`**:\n   - Because `b.Signature` and `b.Signatures` are excluded from `core.HashBlock(b)` (and PoW), `blockValidator` accepts hybrid blocks carrying both `b.Signature` and `b.Signatures`, blocks with >256 multisig signature entries, duplicate signers, or entries with short/non-hex `PublicKey` (`len(sig.PublicKey) < 64`, which triggers an unbounds-checked `pk[:12]` slice panic in `core.VerifyMultisig` at `core/multisig.go:94,99,103`).\n\n## Reproduction (Failing Pre-Fix Test)\n\nRun `go test -race -v ./net -run 'TestGossipSubscribeDeliversMultisigBlocks|TestBlockValidatorMultisigAndMalformedSignatures'`:\n\n```text\n=== RUN   TestGossipSubscribeDeliversMultisigBlocks\n    gossip_multisig_test.go:131: Gossip.Subscribe silently dropped valid multisig block c0a006a9080f (Signature=\"\", len(Signatures)=2)\n--- FAIL: TestGossipSubscribeDeliversMultisigBlocks (2.10s)\n=== RUN   TestBlockValidatorMultisigAndMalformedSignatures\n    gossip_multisig_test.go:158: hybrid Signature+Signatures block: got 0, want ValidationReject\n--- FAIL: TestBlockValidatorMultisigAndMalformedSignatures (0.00s)\nFAIL\nFAIL\tgithub.com/xeprotocol/xe/net\t2.129s\n```\n\n## Proposed Fix\n\n1. Introduce `hasValidBlockSignatures(b *core.Block) bool` in `net/gossip_validate.go` that enforces:\n   - Mutual exclusion between single-key `b.Signature != \"\"` and multisig `len(b.Signatures) > 0` (`hasSingle != hasMulti`).\n   - `isHex128(b.Signature)` when `b.Signature != \"\"`.\n   - `1 <= len(b.Signatures) <= maxMultisigSignatures` (`256`), `isHex64(sig.PublicKey)`, `isHex128(sig.Sig)`, and case-insensitive uniqueness of `sig.PublicKey` across `b.Signatures`.\n2. Use `!isHex64(b.Hash) || !isHex64(b.Account) || !hasValidBlockSignatures(b)` in both `blockValidator` (`net/gossip_validate.go`) and `Gossip.Subscribe` (`net/gossip.go`).\n\n---\n**Payout / Reward Address (Base / EVM / XE)**: `0x45Ecf534fD00bb3179D34E6a3FDdE084cBfBc9Fb`","patch_refs":[{"id":323,"repo":"xeprotocol/xe","kind":"pr","ref":"292","title":"fix(net): deliver multisig blocks in Gossip.Subscribe and validate block signature fields","url":"https://github.com/xeprotocol/xe/pull/292","note":"","state":"open","author":"pa-khan","added_by":"desk","created_at":"2026-11-07T16:36:48.254318+00:00"},{"id":326,"repo":"xeprotocol/xe","kind":"pr","ref":"295","title":"fix(net): deliver multisig blocks in Gossip.Subscribe and validate block signature fields","url":"https://github.com/xeprotocol/xe/pull/295","note":"","state":"open","author":"tipprb","added_by":"desk","created_at":"2026-11-07T19:34:46.381388+00:00"}],"thread":[{"id":3728,"source":"github","source_ref":"6885482952","author":"XE desk","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-1134 and says what differs; it is read like any other.","created_at":"2026-11-14T22:53:24+00:00"}]}