Invalid lease_cancel still unwinds provider accept (cancel-wins before validation)
Report
Invalid lease_cancel still unwinds a provider accept (cancel-wins runs before cancel validation)
Credit: Mgal Ghifari
Target: XE Protocol — https://test.network/bounty
Repo: https://github.com/xeprotocol/xe @ 978785929bc17a2f4ab30c383e5fc9cf4d634512
Component: core/ledger.go — validateAndAddLeaseCancel / resolveCancelWinsOverAccept
Reward address (XE): fe280837c418c6a918cb046d9531648163316d339d93f1498f7b3b9740560570
Summary
An invalid lease_cancel (valid consumer signature, but body fails ledger checks — wrong balance, wrong previous, or timestamp-before-previous) still triggers resolveCancelWinsOverAccept → undoBlockApply and permanently unwinds a provider's not-yet-finalized accept. The unwind runs before the cancel's own pending / previous / timestamp / balance checks. So a block the ledger ultimately rejects still mutates state.
On any node that received that junk cancel: the accept is gone, re-sending the real accept is a silent no-op, after restart the provider's LeasesAcceptedAsProvider reads 0 vs 1 on honest nodes, and the provider's next block fails forever with previous mismatch. Honest nodes that never saw the cancel keep the accept. Lasting node split. Honest-path finality locks the damage — 0 conflicts on the victim, so voting never repairs it.
I'm filing this as High. You could also read it as Severe under XE's wording (validation bypass / node compromise) — a rejected block still corrupts ledger state, and finality locks it. Not Critical: no mint, no double-spend, no escrow theft, and honest nodes that never saw the cancel stay consistent.
Severity
High (XE High tier: targeted DoS / race / privilege escalation a single client can cause)
Also readable as Severe: validation-ordering bug. undoBlockApply runs before the cancel is fully validated, so a block that fails checks still mutates the ledger, and honest finality locks the split.
Not claiming Critical. No mint / double-spend / escrow drain. Honest nodes that never received the junk cancel stay consistent with each other.
Affected code
Commit: 978785929bc17a2f4ab30c383e5fc9cf4d634512
Call site — unwind before cancel checks (core/ledger.go):
// validateAndAddLeaseCancel — lines 1814-1856
if existing != nil && existing.State == LeaseAccepted && existing.Provider != b.Account {
if rerr := l.resolveCancelWinsOverAccept(b.Source, existing.Provider); rerr != nil {
return rerr
}
}
// ... only AFTER that:
// previous mismatch (1842-1843)
// timestamp before previous (1847-1848)
// balance mismatch (1854-1855)
Unwind itself (core/ledger.go:1749-1789):
func (l *Ledger) resolveCancelWinsOverAccept(leaseHash, provider string) error {
// ... find non-finalized tip accept ...
if err := l.undoBlockApply(provider, acceptBlock); err != nil { // line 1784
return fmt.Errorf("cancel-wins: unwind provider accept: %w", err)
}
return nil
}
Gossip delivery (node/node.go:705-711):
func (n *Node) handleIncoming(blocks <-chan *core.Block) {
for b := range blocks {
// ...
err := n.Ledger.AddBlock(b) // every gossiped block, including ones that will be rejected
Why re-sync does not heal (core/ledger.go:793-799): known-hash early return. The rejected accept body stays in the block store, so AddSyncedBlock(accept) returns nil and does nothing.
Preconditions
- A lease exists and a provider has accepted it (
LeaseAccepted), accept not yet finalized. - Attacker is the lease consumer (only the consumer can sign a cancel for that lease).
- Cancel has a valid consumer signature. A bad-sig cancel does not unwind (I checked — credential check runs before cancel-wins). The body is just semantically invalid.
- Delivery: gossip →
AddBlock. StockSubmitBlockwill not re-gossip a rejected cancel. A malicious peer canGossip.Publishthe signed junk cancel directly onto the mesh;handleIncomingfeeds it intoAddBlock. - Window: only before the accept is finalized. Once finalized, cancel-wins refuses with
accept is finalized.
Steps to reproduce
All testing was local — in-memory store.MemStore + in-process core.Ledger. No traffic to test.network. No public load.
PoC lives under reports/poc/ in a checkout of this commit. Relevant tests: h4_cancel_test.go (TestH4b_*), h4b_multinode_test.go, round2_test.go (TestH9_*).
1) Core bug — three invalidity variants
cd /path/to/xe
go test ./reports/poc/ -run 'TestH4b_InvalidCancelStillUnwindsAccept' -v
What you see (each of wrong_balance, wrong_previous, timestamp_before_prev):
- log line:
cancel-wins over a racing accept — unwound provider ... - cancel error e.g.
balance mismatch: expected 1000000, got 1000999(cancel rejected) lease state=created,provider frontier==accept? false, accept status Rejected- re-submit canonical accept:
err=<nil>, frontier still not accept (silent no-op) - provider's next block:
previous mismatch - honest node that never saw the junk cancel:
provider frontier==accept? true
2) Multi-node lasting split + finality lock
go test ./reports/poc/ -run 'TestH4b_MultiNode_LastingSplit|TestH4b_HonestFinalityCannotRepair' -v
Observed:
- junk cancel → victim only: victim lease=
created, honest staysaccepted - honest finalizes accept; victim re-sync of accept:
healed=false, body still in store - victim restart:
accepted-as-provider=0vs honest1 - provider next block on victim: permanent
previous mismatch GetConflictsForAccount(provider)on victim = 0 → voting never engages
3) Amplification (H9) — dual-accept reality after unwind
go test ./reports/poc/ -run 'TestH9_' -v
After the junk cancel on victim, a new accept on the restored frontier:
- victim applies it (
lease=acceptedon a new hash) - honest keeps the original accept frontier and stages a conflict (
conflicts=1) - lasting dual-accept reality across nodes
4) Follow-on refund asymmetry (same root cause)
go test ./reports/poc/ -run 'TestH4b_FollowOn_RefundAfterNetworkFinalizedAccept' -v
After junk cancel on victim, both nodes mark accept finalized network-wide; a later valid cancel:
- victim: succeeds, lease=
cancelled, consumer refunded - honest:
accept is finalized, lease staysaccepted
Same lease, opposite outcomes, depending on who saw the junk cancel.
Root cause
Ordering bug in validateAndAddLeaseCancel:
- See lease in
Accepted→ callresolveCancelWinsOverAccept - That calls
undoBlockApplyand persists the unwind - Then check pending / previous / timestamp / balance
- Those checks fail → cancel is rejected
- Unwind is not rolled back
So a rejected cancel still mutates provider chain + lease state. No conflict object is registered on the provider account, so quorum / finality has nothing to vote on. Honest-side finality of the original accept then freezes the victim on previous mismatch.
Impact
With one signed junk cancel, a lease consumer can:
- Permanently unwind a provider's not-yet-finalized accept on every peer that receives the gossip
- Freeze that provider's account chain on those peers (
previous mismatchforever) - Split node state: affected peers vs honest peers disagree on lease state, frontier, and reputation (0 vs 1 after restart)
- Create a dual-accept reality if a new accept is built on the unwound frontier (H9)
- Leave no on-chain explanation — the cancel itself was rejected
Attack cost: one properly signed consumer block + PoW, delivered via gossip. No special role beyond being the lease consumer.
Suggested fix
- Fully validate the cancel (pending / previous / timestamp / balance — in a staged overlay) before any unwind.
- Only call
resolveCancelWinsOverAccept/undoBlockApplyafter the cancel itself would commit. - Make the unwind part of the cancel's atomic commit (same commit guards /
ExpectLeaseState), so a rejected cancel cannot leave a half-applied unwind. - Optional hardening: delete or tombstone rejected accept bodies so a later re-sync can re-apply the canonical accept instead of hitting the known-hash early return.
Testing note
All of this was local: MemStore + in-process ledgers only. No traffic to test.network, no Track 2 load on the public testnet, no contact with the project before this report.
Thread
PoC source (local MemStore + in-process ledger tests only — no traffic to test.network):
https://gist.github.com/efootballyay-dot/b096fe5ea57de21dcc0ccc8c699cc556
Relevant tests in the gist: TestH4b_*, TestH4b_MultiNode_*, TestH9_*.
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-0017.
Still reproduces at HEAD 89a542e (testnet-0005, 2026-11-10).
validateAndAddLeaseCancel (core/ledger.go:1792-1877) still runs resolveCancelWinsOverAccept before the pending / previous / timestamp / balance checks, so a rejected cancel still permanently unwinds the provider's not-yet-finalized accept.
PoC (local go test, core/zz_poc_area_b_test.go TestPOCAreaB_XE0017_InvalidCancelUnwindsAccept): cancel with balance off by 1 → rejected with balance mismatch, but the lease state reverted to created and the provider chain lost the accept. Fix PRs xe#39 / xe#149 are both still open.