Blockchain.isValid() does not verify sender balance, allowing blocks with negative balances to pass validation
Maintainer thường phản hồi trong vòng 2 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 20/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- java
- Lĩnh vực
- blockchain
Hướng nghiên cứu
Read Blockchain.isValid() and Blockchain.addTransaction() to compare block validation with pending transaction checks. Trace how balances and mining rewards are represented across blocks, then check the README’s validation and balance descriptions. Done means validation rejects a block sequence that makes any sender’s running balance negative; linked pull request #38 is already open.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
In mini-chain, regular transactions submitted locally check that the sender has sufficient balance:
In Blockchain.addTransaction():
if (balanceOf(tx.from()) < tx.amount()) {
return false;
}
This prevents unconfirmed payments from entering the pending pool if the sender cannot afford them.
However, in Blockchain.isValid(), transactions inside mined blocks are only checked for digital signature validity and Merkle tree inclusion:
tx.hasValidSignature()verifies the cryptographic signature with the sender's public key.block.getMerkleRoot()verifies that transaction hashes match the block header.
There is no check verifying whether the sender actually had sufficient coins at the time the block was accepted.
How the Issue Manifests:
- Bypassing the local pool: An adversary with a balance of
0creates and signs a transaction transferring1,000,000coins to another wallet. WhileaddTransaction()would reject this locally, a miner or external peer can include this signed transaction directly into a candidate block. - Valid Cryptography & Proof of Work: Because the transaction was signed with the sender's valid private key,
tx.hasValidSignature()evaluates totrue. The miner calculates the Merkle root and solves the proof-of-work puzzle. - Validation Bypass: When the blockchain is validated across peers via
isValid(), the method only verifies the block hash, Merkle root, difficulty, and signatures. Since every cryptographic check passes,isValid()evaluates totrue. - State Distortion: Once the block is accepted into the chain,
balanceOf(sender)becomes-1,000,000, andbalanceOf(recipient)gains1,000,000unbacked coins that can now be spent across the network.
Expected Behavior
According to the README:
- "Validation:
isValid()returns false if anything in any mined block was changed or if any payment inside it is invalid." - "Balance: Starting at zero, add up all coins received and subtract all coins sent across every mined block."
A transaction spending more coins than the sender's accumulated balance is invalid. Blockchain.isValid() should ensure that no transaction in any block causes the sender's running balance to drop below zero. If an overspending transaction is encountered, isValid() should return false.
Proposed Solution
In Blockchain.isValid():
- Maintain a running balance tracker (e.g.,
Map<String, Integer> runningBalances = new HashMap<>()) as blocks are validated in sequence. - Credit the mining reward to the miner (
tx.to()). - For standard user transactions:
- Check if
runningBalances.getOrDefault(tx.from(), 0) < tx.amount(). If so, returnfalse. - Debit
tx.from()and credittx.to().
- Check if
- Ngôn ngữ chính
- Java
- Star
- 0
- Fork
- 3
- Merge trung bình
- 2 ngày 5 giờ
- Pull request đã merge (30 ngày)
- 15
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của techcsispit/mini-chain
-
README says changing Block or Transaction makes chain.dat stop loading, but adding a field or method still loads itCó thể đã có người làm @tanujb03 đã nhận 26 ngày trước. Đang mởdocumentation good first issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 25/100
techcsispit/mini-chain#21 ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của techcsispit/mini-chain
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
scylladb/scylla-cdc-source-connector#402 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Some walls missing from researchĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
ahmedmmordi/store-app#8 ·
-
jhipster heroku fails on heroku git:remote when reusing an existing app outside a git repositoryĐang mởarea: triage theme: undefined
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
jhipster/generator-jhipster#36018 ·
Maintainer thường phản hồi trong vòng 1 ngày