Skip to content

Instantly share code, notes, and snippets.

Last active Jan 13, 2022
What would you like to do?
pragma solidity ^0.5.0;
* @title Bypasser
* @dev Bypasser is a malicious SimpleTimelock beneficiary that
* allows the owner to divest before the timelock has expired.
contract Bypasser {
// owner of the contract
address payable public owner;
// price required to purchase ownership from current owner
uint256 public price;
// only owner can call functions with this modifier
modifier onlyOwner() {
require(msg.sender == owner, "only owner can call this");
// accept ETH
function () external payable {}
constructor() public {
owner = msg.sender;
// allows current owner to collect any ETH in this contract
function collect() external onlyOwner {
// allows the current owner to set the price of buying ownership
function setPrice(uint256 newPrice) external payable onlyOwner {
price = newPrice;
// allows anyone willing to pay the `price` to become the new owner
function buyOwnership() external payable {
require(price != 0, "cannot buy ownership when the price is 0");
require(msg.value >= price, "did not send enough funds");
uint256 pricePaid = price;
address payable oldOwner = owner;
// set price to zero
price = 0;
// set new owner
owner = msg.sender;
// pay the old owner
Copy link

SFzxc commented Jun 29, 2021

I think uint256 pricePaid = price; should become uint256 pricePaid = msg.value;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment