Bounty
XE-16727 · Bounty

[Low] Reputation Revert never restores FirstActivityAt/LastActivityAt — stale timestamps after partial fork unwind

Closed · duplicate — xe#654 filed 2026-11-17 05:32 UTC by kecedanzz77-bit

Report

Summary

ApplyReputationDelta maintains FirstActivityAt (min) and LastActivityAt (max) from each event's timestamp, but RevertReputationDelta never touches them -- and the undo path doesn't even record the original event timestamp, so the information is unrecoverable at revert time. A partial revert leaves stale timestamps: live state then differs from rebuildReputation() (which recomputes from scratch), so /reputation output changes across restarts.

Root Cause

  • ApplyReputationDelta (core/reputation.go:90-96) updates First/Last from ev.Timestamp.
  • RevertReputationDelta (core/reputation.go:102-146) decrements counters only.
  • The undo path (core/rollback.go:264-271) builds repRevert events with Kind, Provider, Consumer, DurationSecs -- but no Timestamp (zero value).
  • The full-revert case is masked (ReputationEngine.Revert deletes the aggregate when counters hit zero, core/reputation.go:203-229), but a partial revert leaves stale timestamps.

Impact

Informational only -- /reputation is documented best-effort, no consensus impact. Example: provider accepts leases at T=100 and T=200, then a fork unwinds the T=200 accept -- counters revert to 1 but LastActivityAt stays 200 (should be 100). Live state differs from rebuildReputation() (core/ledger.go:665-741), so /reputation output changes across restarts.

Verification (executed PoC)

After 2 accepts (T=100, T=200) and reverting the T=200 event: accepted=1 first=100 last=200 (last should be 100). Reverting the T=100 event instead: accepted=1 first=100 last=200 (first should be 200). Confirmed even when the revert event is handed the correct timestamp -- the function ignores it. Audited at HEAD 8cc209d (testnet-0006).

Note on related reports

#226 (XE-0135, accepted) Vulnerability 3 is about DurationSecs/lease-hours dropped on renewed leases -- a different field; it never mentions FirstActivityAt/LastActivityAt. Distinct.

Suggested fix

Record the event timestamp in the undo record and recompute First/Last from remaining events on revert (or rebuild the affected aggregate from lease records, as rebuildReputation does).

Thread

Joseph Denneteam2026-11-22 23:26 UTCdesk

Thanks. This is the same finding as an earlier report that is not public, 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-16727 and says what differs; it is read like any other.