Blockchain: a payment that was already mined can be submitted again, and it is accepted and mined a second time
メンテナーはふだん 2 日以内に返信
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 52/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- java
- 領域
- blockchain, security
調査の方向性
Start with the reproduction program in the issue, which uses Blockchain.addTransaction, minePending, balanceOf and isValid, plus Transaction.create in package minichain. Find where pending and mined transactions are stored and check whether the transaction id is ever compared against them. Done when the resubmitted transaction is refused, the balances stay at ravi=20 and asha=80, and isValid still returns true.
索引モデルが issue の本文から書いたものです。
説明
What I did
- Fresh checkout of
main, JDK 17, Maven. mvn compile- Save this as
Replay.javain the project folder:
package minichain;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
public class Replay {
public static void main(String[] args) throws Exception {
KeyPairGenerator g = KeyPairGenerator.getInstance("RSA");
g.initialize(1024);
KeyPair asha = g.generateKeyPair();
Blockchain chain = new Blockchain(2);
chain.minePending("asha");
chain.minePending("asha"); // asha has 100 coins
// asha makes ONE payment of 20 coins to ravi and it is mined
Transaction pay = Transaction.create("asha", "ravi", 20, asha.getPrivate(), asha.getPublic());
chain.addTransaction(pay);
chain.minePending("m");
System.out.println("after the one payment: ravi=" + chain.balanceOf("ravi") + ", asha=" + chain.balanceOf("asha"));
// anyone can copy that transaction out of the chain and submit it again, unchanged
Transaction copy = chain.getChain().get(3).getTransactions().get(0);
chain.addTransaction(copy);
chain.addTransaction(copy);
chain.minePending("m");
System.out.println("after resubmitting it twice: ravi=" + chain.balanceOf("ravi") + ", asha=" + chain.balanceOf("asha") + ", chain valid=" + chain.isValid());
}
}
- Compile and run it (use
:instead of;on Linux/macOS):
mkdir out && javac -cp target/classes -d out Replay.java && java -cp "target/classes;out" minichain.Replay
What I expected
Asha authorised one 20-coin payment and was charged 60.
The README says: "The system uses digital signatures to prevent forging transactions." (README.md, Note on Security)
A payment asha made once should only be able to move her coins once. Submitting the same, unchanged transaction again should be refused.
What happened instead
after the one payment: ravi=20, asha=80
after resubmitting it twice: ravi=60, asha=40, chain valid=true
The same transaction id is accepted again (even twice in a row while it is still waiting to be mined), mined, and the chain stays valid. Asha authorised 20 coins and ends up paying 60. Nobody needs her private key: every mined transaction, with its id, public key and signature, is stored in the chain and in chain.dat.
Environment
main @ 0e92205, JDK 17, Maven 3.9.16, Windows 11.
I'd like to work on the fix for this.
- 主要言語
- Java
- スター
- 0
- フォーク
- 3
- 平均マージ
- 2日 5時間
- マージ済み PR(30日)
- 15
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
techcsispit/mini-chain のほかの issue
-
Blockchain.isValid() does not verify sender balance, allowing blocks with negative balances to pass validation対応中かも @aadiitya2007 が 5 日前に担当しました。 オープンbug good first issue
難易度 4/5 1〜2日 初心者へのやさしさ 20/100
techcsispit/mini-chain#37 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
-
README says changing Block or Transaction makes chain.dat stop loading, but adding a field or method still loads it対応中かも @tanujb03 が 24 日前に担当しました。 オープンdocumentation good first issue
難易度 1/5 1時間未満 初心者へのやさしさ 25/100
techcsispit/mini-chain#21 ·
メンテナーはふだん 2 日以内に返信
techcsispit/mini-chain の issue をすべて見る
似ている issue
-
5.0.x backport enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 63/100
spring-cloud/spring-cloud-function#1507 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
open-learning-exchange/myplanet#18484 ·
メンテナーはふだん 1 日以内に返信
-
ai-driven-fuzzing bug claude Minor
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
linagora/twake-calendar-side-service#1417 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
line/armeria#7109 · リアクション 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
open-feature/java-sdk-contrib#1966 ·
メンテナーはふだん 1 日以内に返信