[UTXO-BUG] CRIT-1: Conservation law bypass via negative/zero-value outputs#2067
Conversation
|
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! |
|
Great security audit work! These fixes are critical for the protocol. |
|
Partial overlap with createkr #2063 (merged) which added the The conservation law bypass via negative outputs (not just negative fees) is a distinct attack vector. The float/type check on
Wallet: |
|
Verified against production code. Real vulnerability.
Mitigating factor: The Severity: HIGH with critical defense-in-depth implications. Not currently externally exploitable but becomes critical as UTXO migration completes. Payment: 75 RTC (bounty #2819) Merge order: this PR first, then #2070 rebased on top. Both modify Excellent work as always, @ArokyaMatthew. |
…tputs apply_transaction() never validates that output value_nrtc is positive. A negative-value output reduces output_total, allowing an attacker to create outputs exceeding input_total while the conservation check passes. Attack: 100 RTC input -> [+200 RTC, -100 RTC] outputs output_total = 200 + (-100) = 100 <= input_total = 100 -> PASSES Attacker now has 200 RTC from a 100 RTC input. Fix: validate every output has integer value_nrtc > 0 before the conservation check. Also rejects zero-value dust and float types. Tests added: - test_negative_value_output_rejected - test_zero_value_output_rejected - test_float_value_nrtc_rejected Bounty: #2819 (Critical, 200 RTC)
af816e6 to
3742afc
Compare
|
Rebased onto current Conflict: upstream
Ready to merge. |
|
Payment: 75 RTC transferred to Memo: UTXO CRIT-1: Conservation law bypass via negative outputs — bounty #2819 Thank you for the contribution! |
Bounty Recognition Request — 13 Merged PRsHi @Scottcjn, I've had 13 PRs merged into the RustChain codebase covering security fixes, validation hardening, and test coverage across BFT consensus, UTXO, sync, governance, bridge, and transfer modules. I'd like to request the associated bounty credits be recognized. Merged PRs Summary
All PRs have been reviewed and merged. Each included regression tests and detailed vulnerability descriptions per the bounty guidelines. I have mentioned my wallet in every PR submission. Please credit the above to my wallet when convenient. Thank you for maintaining the bounty program — happy to keep contributing.
|
Vulnerability Class
Critical — Fund creation from nothing (200 RTC bounty)
The Bug
apply_transaction()inutxo_db.pyvalidates thatoutput_total + fee <= input_total, but never validates that individual output values are positive.A negative-value output reduces
output_total, allowing an attacker to create a second output with value exceedinginput_totalwhile the conservation check passes.Attack Vector
output_total = 200 + (-100) = 100 <= input_total = 100 → PASSES
Attacker now has 200 RTC from a 100 RTC input
Fix
Added validation in apply_transaction() that every output must have value_nrtc as a strictly positive integer. This also blocks zero-value UTXO set bloat and float-type values that cause silent SQLite truncation.
Tests Added
test_negative_value_output_rejected — demonstrates the attack above
test_zero_value_output_rejected — blocks zero-value dust outputs
test_float_value_nrtc_rejected — blocks non-integer values
All 37 tests pass.
Files Changed
node/utxo_db.py — 6 lines added (validation block)
node/test_utxo_db.py — 63 lines added (3 test cases)
Ref: Bounty #2819
MY WALLET IS aroky-x86-miner