{"id":"XE-16882","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"682","source_url":"https://github.com/xeprotocol/xe/issues/682","reporter_id":2920,"title":"[Medium] Sync retry loop re-verifies never-appliable retryable blocks twice per round, forever (CPU DoS from one malicious peer)","area":"p2p-sync","claimed_tier":"medium","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-17T07:04:22.874115+00:00","updated_at":"2026-11-22T23:26:12.657932+00:00","source_created_at":"2026-11-17T07:03:47+00:00","told_at":"2026-11-22T23:26:12.718688+00:00","status_changed_at":"2026-11-22T23:26:12.685868+00:00","url":"https://bounty.xe.network/XE-16882","body":"## Summary\n\nThe sync apply loop re-verifies never-appliable retryable blocks **twice per round, forever**, with no quarantine and no peer penalty — so one malicious peer serving validly-signed blocks with bogus parents can burn ~0.3–1.7 cores on a victim indefinitely, repeating every 10 s periodic round.\n\n## Root Cause\n\n`requestSync` (`net/sync.go:826-880`):\n\n1. **Two full passes per round in the all-retryable case.** The retry loop (`:826-852`) calls `ledger.AddSyncedBlock(b)` on every pending block; when all fail retryably it breaks immediately (`if len(retryable) == len(pending) { break }`). The \"collect reasons\" block afterwards (`:854-870`) then calls `ledger.AddSyncedBlock(b)` **a second time** on every remaining block, just to log the error strings.\n2. **Retryable failures are never quarantined.** Only non-retryable failures are quarantined (`:840`) and marked unreachable. A block failing with retryable `previous mismatch` stays appliable-forever.\n3. **`skipUnreachable` (`:811-820`) never helps here.** It only skips blocks whose `Previous` is already in the unreachable set; a bogus parent is merely missing, never marked.\n4. **No peer penalty.** There is no Ban/Disconnect/peer-score call anywhere in `net/sync.go`.\n5. **The frontier never advances**, so the same blocks are re-served every 10 s (`periodicSyncInterval`, `net/sync.go:36`, ticker `:443`).\n\nThe cost is incurred because signature verification happens *before* the parent check: `VerifyBlock` (`core/crypto.go:145-167`) only verifies signatures for open blocks, so non-open blocks pay a full ed25519 verify in `verifyBlockCredential` (`core/ledger.go:1474`, called at `:859`) before failing with `previous mismatch` (`core/ledger.go:1040`, same error at other apply sites).\n\n## Impact\n\nAttack: a malicious peer serves validly-signed blocks whose `Previous` doesn't exist. Each block passes hash + PoW + full ed25519 verification, then fails retryably — twice per round, every 10 s, forever.\n\nMeasured (executed PoC, 2,000 validly-signed bogus-parent sends):\n\n```\npass 1 (retry 0): 1.20s for 2000 blocks (601.0 us/block); retryable=2000 other-err=0 nil=0\npass 2 (final pass): 1.47s for 2000 blocks (737.2 us/block); retryable=2000 other-err=0 nil=0\nsample error: previous mismatch\n```\n\nExtrapolation: 10,000 blocks × 2 passes × ~670 µs ≈ **13 s CPU/round/peer** at VM rates (≈3–4 s bare metal), repeating every 10 s — one peer sustains ~0.3–1.7 cores indefinitely, ×4 concurrent rounds. Attacker cost is one-time (sign 10k blocks once, re-serve ~5 MB/round). Amplifier: #613 (sync caps bypassed by framing) lets a peer serve *more* than 10k blocks/round.\n\n## Note on related reports\n\nDistinct from #245 (opposite direction — the client *discards* retryable blocks after 10 passes, honest-server livelock), #613 (cap bypass; complementary amplifier, different mechanism), #167 (quarantine poisoning), #59 (honest first-sync memory, no in-flight guard), and #633 (junk block blocking lease archiving — different mechanism and impact). Searched \"sync retry re-verify AddSyncedBlock\" — no covering report.\n\n## Suggested fix\n\nQuarantine blocks failing retryably in 2 consecutive rounds (time-bounded); record errors from the retry loop instead of re-verifying in the reasons pass; penalize peers with high served-block failure rates.\n","patch_refs":[],"thread":[{"id":18811,"source":"desk","source_ref":"reply:16488","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-16882 and says what differs; it is read like any other.","created_at":"2026-11-22T23:26:12.657932+00:00"}]}