Bounty
XE-10033 · Bounty

CLI Self-Fork Race Condition: cmdReceive loops multiple pending blocks without frontier propagation creating intra-account conflicts

Closed · invalid — web filed 2026-11-12 09:26 UTC by xe:e4cd6974

Report

Vulnerability Summary

In cmd/xe/main.go:747-781, cmdReceive() loops over unreceived pending transfers to construct and submit BlockReceive transactions:

	fmt.Printf("Receiving %d pending send(s)...
", len(pending))
	for _, p := range pending {
		chain, _ := c.GetChain(addr)
		bals, _ := c.GetBalances(addr)

		prev := "0"
		if len(chain) > 0 {
			prev = chain[len(chain)-1].Hash
		}

		b := &core.Block{
			Type:      core.BlockReceive,
			Account:   addr,
			Previous:  prev,
			Balance:   bals[p.Asset] + p.Amount,
			Timestamp: time.Now().UnixNano(),
			Asset:     p.Asset,
			Source:    p.SendHash,
		}
...
		if err := c.SubmitBlock(b, "receive"); err != nil {
			fmt.Fprintf(os.Stderr, "  skip %s: %v
", shortHash(p.SendHash), err)
			continue
		}

When an account has multiple pending transfers (len(pending) > 1), cmdReceive() processes them in rapid succession. On iteration 0, block $B_0$ is submitted to the node.

Because c.SubmitBlock returns before the network or local store propagates the new frontier block, iteration 1 immediately queries c.GetChain(addr) and c.GetBalances(addr). The node's store has not yet committed $B_0$ or updated chain[len(chain)-1].

As a result:

  1. Iteration 1 receives the exact same frontier prev and the exact same stale bals[p.Asset].
  2. Iteration 1 generates block $B_1$ pointing to the same Previous: prev as $B_0$.
  3. Two blocks with identical Previous hashes are broadcast to the network for the same account.

Impact & Severity

  1. Account Deadlock: Emitting two blocks with the same Previous pointer triggers an immediate fork conflict (core.ErrForkDetected) on the user's own lattice account.
  2. Quorum Lockout: The account's chain is frozen into conflict arbitration in core.QuorumManager, blocking subsequent receives and sends until external representatives cast votes.
  3. Balance Corruption: Stale balance computation in subsequent iterations leads to consensus rejection with balance mismatch.

Proposed Remediation

In cmdReceive(), track local frontier state and balance offsets in-memory across loop iterations:

	currentPrev := prev
	currentBalances := bals
	for _, p := range pending {
		b := &core.Block{
			Type:      core.BlockReceive,
			Account:   addr,
			Previous:  currentPrev,
			Balance:   currentBalances[p.Asset] + p.Amount,
...
		}
...
		currentPrev = b.Hash
		currentBalances[p.Asset] += p.Amount
	}

Thread

XE deskteam2026-11-20 00:48 UTCdesk

Thanks for the report. We read it against the code and could not confirm a bug in what it describes.

This report is closed as invalid. If we have missed something, file a new report that links https://bounty.xe.network/XE-10033 and says what; it is read like any other.