Pending Send List Duplication: PutPendingSend and CommitUndo omit deduplication on destination index causing phantom duplicate receives
Report
Vulnerability Summary
In store/badger_store.go:224-232 and 1060-1070 (and store/mem_store.go:120-135), PutPendingSend and CommitUndo.AddPending index pending transactions by destination account:
destKey := prefixedKey(prefixPendingDst, ps.Destination)
var hashes []string
item, err := txn.Get(destKey)
if err != nil && err != badger.ErrKeyNotFound {
return err
}
if err == nil {
if err := item.Value(func(val []byte) error {
return json.Unmarshal(val, &hashes)
}); err != nil {
return err
}
}
hashes = append(hashes, ps.SendHash)
destData, err := json.Marshal(hashes)
if err != nil {
return err
}
return txn.Set(destKey, destData)
Notice that hashes = append(hashes, ps.SendHash) unconditionally appends the send block hash to the destination's pending list slice without deduplication:
- Idempotency Failure: If
PutPendingSendis executed more than once for the same send transaction (e.g. during p2p block synchronization re-runs, block re-announcements, or cascade reorg rollbacks), the transaction hash is appended multiple times:["sendHashA", "sendHashA"]. - Duplicate API & CLI Responses:
GetPendingByDestiterates throughhashesand fetches each item viaGetPendingSend(h). It returns a slice containing duplicate*core.PendingSendrecords to API callers (GET /pending/{address}). - Client Double-Receive Conflict: Automated client tools and CLI (
xe receive) iterate overc.GetPending(addr)and attempt to construct and submit multipleBlockReceiveblocks referencing the same send hash, causing transaction rejection or self-fork conflicts.
Proposed Remediation
In store/badger_store.go and store/mem_store.go, ensure hashes is deduplicated before appending:
alreadyPresent := false
for _, h := range hashes {
if h == ps.SendHash {
alreadyPresent = true
break
}
}
if !alreadyPresent {
hashes = append(hashes, ps.SendHash)
}
Thread
Thanks. This is the same finding as https://bounty.xe.network/XE-0135, which was filed first; the programme pays the first verifiable submission, so this one closes as a duplicate. If you believe it is a different bug, file a new report that links https://bounty.xe.network/XE-10134 and says what differs; it is read like any other.