12 ms·
This function will reduce user balances, before the vulnerable withdraw function is called. So, instead of the logging function, we should have: if (!transfer(
by winteriscoming 10y ago
This function will reduce user balances, before the vulnerable withdraw function is called. So, instead of the logging function, we should have:
if (!transfer(0 , balances[msg.sender])) { throw; }
This would <snip>.... also reduce the tokens available to the user later on
The more I think of the typo and the explanation about it in that article, the more unclear I am about that whole code.
Keeping aside this hack, for a moment, if that is indeed a typo and instead it should have called the lower case transfer method to really reduce the user tokens, then does this mean that all these DAO contracts (or whatever the right term is) that have been executed till date have been affected by this and as such the entire eco-system state was already messed up before this hack?
Nothing in that article suggests that this code flow, where this apparent typo is present, is applicable only for this specific hack.
- caf 10y agoNo, because after the call to Transfer() and withdrawRewardFor(), it sets their balance to zero: totalSupply -= balances[msg.sender]; balances[msg.sender] = 0; paidOut[msg.sender] = 0; So the bug is only exposed if the recipient of the reward transfers out the balance during the execution of withdrawRewardFor(). In fact, to me it doesn't look like there's a typo at all there - the call to Transfer() was fully intended just to log the burning of the tokens that will be accomplished by the later lines setting the balance to zero. The bug is simply that the balance isn't adjusted before the attacker gets a chance to execute code.
- htns 10y agoThe top comment on /r/ethereum agrees with you on it not being a typo: https://www.reddit.com/r/ethereum/comments/4onbkj/deconstructing_thedao_attack_a_brief_code_tour/ https://www.reddit.com/r/ethereum/comments/4onbkj/deconstruc... . Hopefully in a few days we will have an authoritative explanation. Otherwise this might become a HN urban legend.