Created
September 11, 2020 21:03
-
-
Save epheph/460e6ff4f02c4ac582794a41e1f103bf to your computer and use it in GitHub Desktop.
bad-contract.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.5.11; | |
// THIS CONTRACT HAS INTENTIONAL VULNERABILITY, DO NOT COPY | |
contract Victim { | |
mapping (address => uint256) public balances; | |
function deposit() external payable { | |
balances[msg.sender] += msg.value; | |
} | |
function withdraw() external { | |
uint256 amount = balances[msg.sender]; | |
(bool success, ) = msg.sender.call.value(amount)(""); | |
require(success); | |
balances[msg.sender] = 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment