{"id":"XE-16727","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"654","source_url":"https://github.com/xeprotocol/xe/issues/654","reporter_id":2920,"title":"[Low] Reputation Revert never restores FirstActivityAt/LastActivityAt — stale timestamps after partial fork unwind","area":"node-api","claimed_tier":null,"assessed_tier":null,"verdict":"duplicate","duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":"","status":"closed","closed_reason":"duplicate","github_state":"open","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-17T05:34:14.999073+00:00","updated_at":"2026-11-22T23:26:16.834690+00:00","source_created_at":"2026-11-17T05:32:41+00:00","told_at":"2026-11-22T23:26:16.848189+00:00","status_changed_at":"2026-11-22T23:26:16.839412+00:00","url":"https://bounty.xe.network/XE-16727","body":"## Summary\n`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.\n\n## Root Cause\n- `ApplyReputationDelta` (`core/reputation.go:90-96`) updates First/Last from `ev.Timestamp`.\n- `RevertReputationDelta` (`core/reputation.go:102-146`) decrements counters only.\n- The undo path (`core/rollback.go:264-271`) builds `repRevert` events with `Kind`, `Provider`, `Consumer`, `DurationSecs` -- but no `Timestamp` (zero value).\n- 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.\n\n## Impact\nInformational 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.\n\n## Verification (executed PoC)\nAfter 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).\n\n## Note on related reports\n#226 (XE-0135, accepted) Vulnerability 3 is about `DurationSecs`/lease-hours dropped on renewed leases -- a different field; it never mentions `FirstActivityAt`/`LastActivityAt`. Distinct.\n\n## Suggested fix\nRecord 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).","patch_refs":[],"thread":[{"id":18874,"source":"desk","source_ref":"reply:16551","author":"Joseph Denne","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-16727 and says what differs; it is read like any other.","created_at":"2026-11-22T23:26:16.834690+00:00"}]}