Repository navigation
[SYNC-BUG] HIGH-SYNC-2: Peer sync accepts arbitrary balance increases… - #2089
Merged
Scottcjn merged 1 commit intoApr 5, 2026
Merged
Conversation
… — wallet inflation apply_sync_payload() for the 'balances' table only rejects sync data that would DECREASE a local balance, but accepts any INCREASE. A compromised peer node can sync a fabricated row setting any wallet to any value (e.g. miner-alice: 999,000,000 µRTC). Balances are authoritative state that must only change through local transaction processing (rewards, transfers, epoch settlements), never via peer sync. Fix: Reject ALL balance modifications (increases AND decreases) from peer sync for wallets that already have a local row. New wallets (no local row) can still be created via sync for initial propagation. Tests added (new file test_sync_balance_inflation.py): - test_balance_increase_rejected (demonstrates the bug) - test_balance_decrease_still_rejected (existing protection) - test_new_wallet_from_sync_allowed (non-regression) - test_unchanged_balance_passes (identical sync is a no-op) All 4 tests pass. Bounty: Scottcjn#2819 (High, 100 RTC)
Contributor
|
Welcome to RustChain! Thanks for your first pull request. Before we review, please make sure:
Bounty tiers: Micro (1-10 RTC) | Standard (20-50) | Major (75-100) | Critical (100-150) A maintainer will review your PR soon. Thanks for contributing! |
Owner
|
Excellent find. The old code only rejected balance decreases from peers — a compromised node could inflate any wallet by syncing a higher value. Your fix correctly blocks ALL balance modifications via sync (both up and down), while still allowing new wallet creation for initial propagation. The test suite is thorough: covers inflation, decrease, new wallet, and no-op cases. Payment: 75 RTC (balance inflation via peer sync, high severity — single compromised node could mint arbitrary funds) Merging. |
This was referenced Apr 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🛡️ Vulnerability Class
High — Arbitrary wallet inflation via peer sync (100 RTC bounty)
🧠 The Bug
The
sync_payload()inrustchain_sync.pyhas a balance conflict resolution check that only rejects sync data that would decrease a local balance.This allows malicious peers to increase balances silently, resulting in unauthorized inflation.
❌ Before (vulnerable)
💥 Impact
Any peer node can inflate any wallet to arbitrary values
Breaks financial integrity of the system
No authentication or authority required
✅ Fix
Reject ALL balance modifications (both increases AND decreases) for wallets that already exist locally.
Allow sync only for:
New wallets (initial propagation)
Non-financial metadata
✔️ After (fixed)
Files Changed
node/rustchain_sync.py — reject all balance modifications from peers
node/test_sync_balance_inflation.py — NEW test file (4 tests)
Wallet: aroky-x86-miner