A signed payment can be altered (payee and amount) and still pass signature verification
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 55/100
Research direction
Start with the signing and verification code in the Transaction class: look at Transaction.create, the four-argument constructor, and hasValidSignature(), and check which fields the signature actually covers. Then look at Blockchain.addTransaction and isValid(). Run the Repro.java from the issue against target/classes. Done means the forged payment fails hasValidSignature(), the chain rejects it, and the existing tests still pass. Agree on the signed fields with the maintainer first.
Written by the indexing model from the issue text.
Description
What I did
- Fresh checkout of
main, JDK 17, Maven. mvn compile- Save this as
Repro.javain the project folder:
package minichain;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
public class Repro {
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"); // asha now has 50 coins
// asha signs a payment of 120 coins to "ravi"
Transaction signed = Transaction.create("asha", "ravi", 120, asha.getPrivate(), asha.getPublic());
// same id, key and signature, but a different payee and amount
Transaction forged = new Transaction(signed.id(), "asha", "ravi1", 20, signed.senderKey(), signed.signature());
System.out.println("signed: " + signed);
System.out.println("forged: " + forged);
System.out.println("signature valid for the forged payment: " + forged.hasValidSignature());
chain.addTransaction(forged);
chain.minePending("m");
System.out.println("chain valid: " + chain.isValid() + ", ravi1 has " + chain.balanceOf("ravi1") + " coins");
}
}
- Compile and run it (use
:instead of;on Linux/macOS):
mkdir out && javac -cp target/classes -d out Repro.java && java -cp "target/classes;out" minichain.Repro
What I expected
The README says: "The system uses digital signatures to prevent forging transactions." (README.md, Note on Security)
A payment whose payee or amount differs from what asha signed should fail hasValidSignature().
What happened instead
signed: asha -> ravi: 120
forged: asha -> ravi1: 20
signature valid for the forged payment: true
chain valid: true, ravi1 has 20 coins
The id, key and signature are all public in the chain.
Environment
main @ 0e92205, JDK 17, Maven 3.9.16, Windows 11.
I'd like to work on the fix for this.
- Dominant language
- Java
- Stars
- 0
- Forks
- 3
- Avg merge
- 16h 38m
- Merged PRs (30d)
- 7
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from techcsispit/mini-chain
-
Tests: no test covers a payment of 0 or the genesis block meeting the difficultyPossibly taken @tanujb03 claimed this 2 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
techcsispit/mini-chain#23 ·
Maintainers usually reply within 1 day
-
README says changing Block or Transaction makes chain.dat stop loading, but adding a field or method still loads itPossibly taken @tanujb03 claimed this 2 days ago. Opendocumentation good first issue
Difficulty 1/5 Under an hour Newbie friendliness 25/100
techcsispit/mini-chain#21 ·
Maintainers usually reply within 1 day
-
BlockchainTest: signature tampering tests pass on the hash check; Block.mine() is a no-op so signature verification is not testedPossibly taken @tanujb03 claimed this 2 days ago. Opengood first issue tests
Difficulty 3/5 1-2 days Newbie friendliness 25/100
techcsispit/mini-chain#19 ·
Maintainers usually reply within 1 day
-
Blockchain: a payment that was already mined can be submitted again, and it is accepted and mined a second timePossibly taken @tanujb03 claimed this 2 days ago. Openbug good first issue
Difficulty 3/5 1-2 days Newbie friendliness 52/100
techcsispit/mini-chain#16 ·
Maintainers usually reply within 1 day
All issues in techcsispit/mini-chain
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
quelea-projection/Quelea#711 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ShaftHQ/SHAFT_ENGINE#6909 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
mudler/parakeet.cpp#99 ·
Maintainers usually reply within 1 day
-
[BUG] Re-subscribing the Mono returned by listTools/listResources/listResourceTemplates/listPrompts/listRoots duplicates the resultsPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
modelcontextprotocol/java-sdk#1174 · 1 reaction ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
baomidou/mybatis-plus#7185 ·