Blockchain: a payment that was already mined can be submitted again, and it is accepted and mined a second time
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 52/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- java
- Ambito
- blockchain, security
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Java
- Stelle
- 0
- Fork
- 3
- Merge medio
- 16h 38m
- PR unite (30g)
- 7
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di techcsispit/mini-chain
-
Tests: no test covers a payment of 0 or the genesis block meeting the difficultyForse già presa @tanujb03 l’ha presa 3 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
techcsispit/mini-chain#23 ·
I maintainer di solito rispondono entro 1 giorno
-
Enhancement: Modernize Cryptographic & Data Architecture (Merkle Trees, Ed25519, Deterministic Hashing & Address Derivation)Forse già presa @sohanjadyal l’ha presa oggi. Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
techcsispit/mini-chain#27 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
README says changing Block or Transaction makes chain.dat stop loading, but adding a field or method still loads itForse già presa @tanujb03 l’ha presa 3 giorni fa. Apertadocumentation good first issue
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 25/100
techcsispit/mini-chain#21 ·
I maintainer di solito rispondono entro 1 giorno
-
BlockchainTest: signature tampering tests pass on the hash check; Block.mine() is a no-op so signature verification is not testedForse già presa @tanujb03 l’ha presa 3 giorni fa. Apertagood first issue tests
Difficoltà 3/5 1-2 giorni Idoneità per principianti 25/100
techcsispit/mini-chain#19 ·
I maintainer di solito rispondono entro 1 giorno
-
A signed payment can be altered (payee and amount) and still pass signature verificationForse già presa @tanujb03 l’ha presa 3 giorni fa. Apertaadvanced bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
techcsispit/mini-chain#15 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di techcsispit/mini-chain
Issue simili
-
:ml/Transform >bug Team:ML
Difficoltà 2/5 Mezza giornata Idoneità per principianti 64/100
elastic/elasticsearch#161960 · 2 commenti · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 4 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
objectionary/lints#1556 ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
wildfly/wildfly-launcher#99 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
apache/rocketmq#11427 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno