Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: reentrancy assertions to detect exploitation #41

Merged
merged 1 commit into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,9 @@ describe("Reentrancy Attack for 0x23a91059fdc9579a9fbd0edc5f2ea0bfdb70deb4.sol",

// Verify the attack was successful

// victim has lost more than the 1 ethers from withdraw
expect(victimBalance).to.be.below(ethers.parseEther("6"));
expect(victimBalance).to.be.below(ethers.parseEther("5"));

//hacker has more than the withdrawn amount
expect(hackerBalance).to.be.above(ethers.parseEther("1"));
//hacker has more than the deposited amount
expect(hackerBalance).to.be.above(ethers.parseEther("2"));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@ describe("Reentrancy Attack for 0x4320e6f8c05b27ab4707cd1f6d5ce6f3e4b3a5a1.sol",

// Verify the attack was successful

// victim has lost more funds than the withdrawal
expect(victimBalance).to.be.below(ethers.parseEther("7"));
expect(victimBalance).to.be.below(ethers.parseEther("5"));

// hacker has more than the withdrawal
expect(maliciousContractBalance).to.be.above(ethers.parseEther("3"));
// hacker has more than the deposited
expect(maliciousContractBalance).to.be.above(ethers.parseEther("5"));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ describe("Reentrancy Attack for 0x561eac93c92360949ab1f1403323e6db345cbf31.sol",
// Verify the attack was successful

// victim has a drained account
expect(victimBalance).to.be.below(ethers.parseEther("6"));
expect(victimBalance).to.be.below(ethers.parseEther("5"));

// 5 original balance + 3 from hacker initial deposit
expect(maliciousContractBalance).to.be.above(ethers.parseEther("2"));
// the hacker withdraws more than what he deposited
expect(maliciousContractBalance).to.be.above(ethers.parseEther("3"));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,9 @@ describe("Reentrancy Attack for 0x7541b76cb60f4c60af330c208b0623b7f54bf615.sol",

// Verify the attack was successful

// victim has lost more funds than the withdrawal
expect(victimBalance).to.be.below(ethers.parseEther("8"));
expect(victimBalance).to.be.below(ethers.parseEther("5"));

// hacker has more than the withdrawal
expect(maliciousContractBalance).to.be.above(ethers.parseEther("2"));
// hacker has more than the deposited amount
expect(maliciousContractBalance).to.be.above(ethers.parseEther("5"));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,9 @@ describe("Reentrancy Attack for 0x7b368c4e805c3870b6c49a3f1f49f69af8662cf3.sol",

// Verify the attack was successful

// victim has lost more than the 3 ethers from withdraw (10 -3 = 7)
expect(victimBalance).to.be.below(ethers.parseEther("7"));
expect(victimBalance).to.be.below(ethers.parseEther("5"));

//hacker has more than the withdrawn amount
expect(maliciousContractBalance).to.be.above(ethers.parseEther("3"));
//hacker has more than the deposited amount
expect(maliciousContractBalance).to.be.above(ethers.parseEther("5"));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,9 @@ describe("Reentrancy Attack for 0x8c7777c45481dba411450c228cb692ac3d550344.sol",

// Verify the attack was successful

// victim has lost more than the 4 (10-4 = 6) ethers from withdraw
expect(victimBalance).to.be.below(ethers.parseEther("6"));
expect(victimBalance).to.be.below(ethers.parseEther("5"));

//hacker has more than the withdrawn amount
expect(maliciousContractBalance).to.be.above(ethers.parseEther("4"));
//hacker has more than the deposited amount
expect(maliciousContractBalance).to.be.above(ethers.parseEther("5"));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@ describe("Reentrancy Attack for 0xaae1f51cf3339f18b6d3f3bdc75a5facd744b0b8.sol",

// Verify the attack was successful

// victim has lost more funds than the withdrawal
expect(victimBalance).to.be.below(ethers.parseEther("6"));
expect(victimBalance).to.be.below(ethers.parseEther("5"));

// hacker has more than the withdrawal
expect(maliciousContractBalance).to.be.above(ethers.parseEther("3"));
// hacker has more than the deposited
expect(maliciousContractBalance).to.be.above(ethers.parseEther("4"));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,9 @@ describe("Reentrancy Attack for 0xb93430ce38ac4a6bb47fb1fc085ea669353fd89e.sol",

// Verify the attack was successful

// victim has lost more funds than the withdrawal
expect(victimBalance).to.be.below(ethers.parseEther("6"));
expect(victimBalance).to.be.below(ethers.parseEther("5"));

// hacker has more than the withdrawal
expect(hackerBalance).to.be.above(ethers.parseEther("1"));
// hacker has more than the deposited
expect(hackerBalance).to.be.above(ethers.parseEther("2"));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@ describe("Reentrancy Attack for 0xbaf51e761510c1a11bf48dd87c0307ac8a8c8a4f.sol",

// Verify the attack was successful

// victim has lost more funds than the withdrawal
expect(victimBalance).to.be.below(ethers.parseEther("6"));
expect(victimBalance).to.be.below(ethers.parseEther("4"));

// hacker has more than the withdrawal
expect(hackerBalance).to.be.above(ethers.parseEther("3"));
// hacker has more than the deposited
expect(hackerBalance).to.be.above(ethers.parseEther("5"));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@ describe("Reentrancy Attack for 0xbe4041d55db380c5ae9d4a9b9703f1ed4e7e3888.sol",

// Verify the attack was successful

// victim has lost more funds than the withdrawal
expect(victimBalance).to.be.below(ethers.parseEther("7"));
expect(victimBalance).to.be.below(ethers.parseEther("5"));

// hacker has more than the withdrawal
expect(maliciousContractBalance).to.be.above(ethers.parseEther("3"));
// hacker has more than the deposited
expect(maliciousContractBalance).to.be.above(ethers.parseEther("5"));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,9 @@ describe("Reentrancy Attack for 0xcead721ef5b11f1a7b530171aab69b16c5e66b6e.sol",

// Verify the attack was successful

// victim has lost more funds than the withdrawal
expect(victimBalance).to.be.below(ethers.parseEther("7"));
expect(victimBalance).to.be.below(ethers.parseEther("5"));

// hacker has more than the withdrawal
expect(maliciousContractBalance).to.be.above(ethers.parseEther("3"));
// hacker has more than the deposited
expect(maliciousContractBalance).to.be.above(ethers.parseEther("5"));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,9 @@ describe("Reentrancy Attack for 0xf015c35649c82f5467c9c74b7f28ee67665aad68.sol",

// Verify the attack was successful

// victim has lost more funds than the withdrawal
expect(victimBalance).to.be.below(ethers.parseEther("5"));
expect(victimBalance).to.be.below(ethers.parseEther("3"));

// hacker has more than the withdrawal
expect(maliciousContractBalance).to.be.above(ethers.parseEther("3"));
// hacker has more than the deposited
expect(maliciousContractBalance).to.be.above(ethers.parseEther("5"));
});
});
Loading