Skip to content

Instantly share code, notes, and snippets.

@ac12644
Last active March 22, 2022 17:42
Show Gist options
  • Save ac12644/c29dfaacdc3bc9761e0d83786793bb38 to your computer and use it in GitHub Desktop.
Save ac12644/c29dfaacdc3bc9761e0d83786793bb38 to your computer and use it in GitHub Desktop.
Vulnerable Contract
contract EtherStore {
uint256 public withdrawalLimit = 1 ether;
mapping(address => uint256) public lastWithdrawTime;
mapping(address => uint256) public balances;
function depositFunds() external payable {
balances[msg.sender] += msg.value;
}
function withdrawFunds (uint256 _weiToWithdraw) public {
require(balances[msg.sender] >= _weiToWithdraw);
// limit the withdrawal
require(_weiToWithdraw <= withdrawalLimit);
// limit the time allowed to withdraw
require(now >= lastWithdrawTime[msg.sender] + 1 weeks);
require(msg.sender.call.value(_weiToWithdraw)());
balances[msg.sender] -= _weiToWithdraw;
lastWithdrawTime[msg.sender] = now;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment