39 votes
Accepted

What is a recursive calling vulnerability?

A Simpler Explanation The attacker creates a wallet contract (0xc0ee9db1a9e07ca63e4ff0d5fb6f86bf68d47b89 in the 17/06/2016 attack) with a default (or fallback) function () to call The DAO's splitDAO(...
BokkyPooBah's user avatar
  • 40.3k
23 votes

Is transfer() still safe after the Istanbul update?

transfer() and send() should be avoided (because they take a hard dependency on gas costs by forwarding a fixed amount of gas: 2300). Gas specific code (call{gas: ..., value: ...}("")) ...
eth's user avatar
  • 85.7k
22 votes
Accepted

How much computation can be done in a fallback function?

The fallback function can do as much computation as how much gas it gets. There are 2 cases (basically recipient.send and recipient.call{value:...}("")) and case 2 has security implications ...
eth's user avatar
  • 85.7k
16 votes

What is a recursive calling vulnerability?

If your code looks like this in pseudo code: function do: if (pool has mymoney = true) split(mymoney) pool has mymoney = false By repeatedly calling that function, you have sort of a ...
Roland Kofler's user avatar
12 votes

TheDAO hack FAQ: How did the attack happen on 17 June 2016?

What happened? 3,641,694 ETH where splitted out of theDAO. The attacker found a loophole in the regular splitDAO function so that they could reuse the same DAO tokens over and over again. How ...
10 votes
Accepted

Callstack attack

Call depth attack A. No. If the call depth is at 1024, employeeAddress.send will fail. The depth remains at 1024 and bossAddress.send will also fail. The depth will only decrease to 1023 when ...
eth's user avatar
  • 85.7k
7 votes

What is a recursive calling vulnerability?

A "recursive calling vulnerability" is an ambiguous term that should be avoided because it is imprecise and can mean 2 things. Reentrant attack You probably mean "reentrancy vulnerability" or "...
eth's user avatar
  • 85.7k
7 votes
Accepted

What does msg.sender.call() do in Solidity?

It calls the anonymous fallback function on msg.sender. In a typical reentrancy attack, it would be something like a withdraw function doing msg.sender.call.value(1 ether)(). The caller (a smart ...
user19510's user avatar
  • 28k
7 votes

Is transfer() still safe after the Istanbul update?

the above answer is perfect, just notice the change in syntax in the latest version of Solidity. someAddress.call{value: 1 ether}('');
Bitnician's user avatar
7 votes
Accepted

Is reentrancy guard needed in ERC 721 minting process and why so?

TL;DR: _safeMint is not that safe. So ensure your mint process is safe. Take a look at the mint method here contract code, require(_mintAmount <= maxMint, "Cant mint more then maxmint" ); ...
Jimson James's user avatar
6 votes
Accepted

Is address.send() not vulnerable for the recursive call attack?

.send will only provide 2300 gas to the fallback function and is safe. But you should carefully check and handle the return value of .send, because of the "call depth attack": How does the stack ...
eth's user avatar
  • 85.7k
6 votes

TheDAO hack FAQ: How did the attack happen on 17 June 2016?

A very highlevel, very simplified answer. If you send a split request to the DAO, it checks your token account, creates a new copy of the DAO with your ethers in it and then reduces your account by ...
6 votes
Accepted

Checking Reentrancy Vulnerability in smart contracts

In case the danger and the pattern isn't clear, a contract is vulnerable if it calls, sends or transfers to an untrusted address (contract with fallback function?) and then updates the state afterward....
Rob Hitchens's user avatar
  • 55.2k
6 votes

What does msg.sender.call() do in Solidity?

msg.sender.call() calls the fallback-function on msg.sender. Here is an example that is extended with a canBeAttacked function. contract Mutex { bool locked; modifier noReentrancy() { require(!...
eth's user avatar
  • 85.7k
6 votes
Accepted

How does the re-entrancy guard modifier work?

The code: modifier modi() { prolog(); _; epilog(); } function func() modi() { stuff(); } Is equivalent to: function func() { prolog(); stuff(); epilog(); } If func is ...
goodvibration's user avatar
5 votes

How was the recursion created that lead to theDAO hack?

This is the problematic line of code in the withdrawRewardFor function: if (!rewardAccount.payOut(_account, reward)) <-- reentrant exploit throw; paidOut[_account] += reward; The ...
Ismael's user avatar
  • 30.6k
5 votes
Accepted

Is a suiciding contract susceptible to re-entrancy?

No, there are no contract invocations with a selfdestruct (suicide), so there is no possibility of reentrancy. There are no CALLs as you've noted and the Geth code you've quoted is correct.
eth's user avatar
  • 85.7k
5 votes

What does `call.value` mean and how did it allow the attack to The DAO?

EDIT Dec 2019: call.value()() should now be used for transferring ether. See: Is transfer() still safe after the Istanbul update (2300 gas limitation)? The following is the original answer. ...
eth's user avatar
  • 85.7k
5 votes
Accepted

How does reentrancy work?

Reentrancy can happen when a contracts critical variable is updated after a call to an external contract that depends on this critical variable to happen. Here's a classic example contract BadBank { ...
Foxxxey's user avatar
  • 4,307
4 votes
Accepted

Is it possible to use negative gas to execute a Reentrant attack using .send()?

It's not possible because the negative gas is accumulated in a separate refund counter and only provided at the very end of the transaction (up to a maximum of half the gas used). See What are the ...
eth's user avatar
  • 85.7k
4 votes

Give some examples of documentation that talks about reentrancy attacks / recursive call vulnerabilities

Before June 2016 August 2014: Reentrant Contracts gives an example of "a contract can be tricked into calling itself". July 2015: LeastAuthority Ethereum Analyses mentioned: reentrancy hazards if ...
eth's user avatar
  • 85.7k
4 votes

Give some examples of documentation that talks about reentrancy attacks / recursive call vulnerabilities

If you are a developer or interested in recreating the attack, I've created two contracts for the purpose of demonstrating exactly how it worked. https://github.com/joeb000/mock-dao-hack There are ...
joeb000's user avatar
  • 253
4 votes
Accepted

Does `address.transfer` forward all gas (suceptible to re-entrancy)?

I setup a minimal test example that you can find on https://gist.github.com/anonymous/07d4714c27dbf1af0e5cb16c9f833353 pragma solidity ^0.4.11; contract Test { Receiver myR; function ...
SCBuergel's user avatar
  • 8,774
4 votes

Solidity msg.sender.send security problem?

Both send() and transfer() are subject to the 2300 gas stipend. The main difference between them is that transfer throws on error and that transfer() supports the .gas() modifier, allowing you to ...
pabloruiz55's user avatar
  • 7,696
4 votes

How does the re-entrancy guard modifier work?

My understanding is that: The counter is incremented A copy of the value of counter is kept Control is returned (https://solidity.readthedocs.io/en/v0.6.8/contracts.html#function-modifiers) There ...
abcoathup's user avatar
  • 1,338
3 votes

Solidity: Examples of fail safe code for security

ConsenSys has a few very good code snippets in their best practices for software engineering. Copy-pasting their Circuit Breaker example: bool private stopped = false; address private owner; ...
Paul Razvan Berg's user avatar
3 votes
Accepted

Solidity: Examples of fail safe code for security

Contracts always have a 'state' which is comprised of the current values of all its variables and its current Ether balance. I suppose they want you to think about which states are allowed to happen, ...
Jesbus's user avatar
  • 10.5k
3 votes

In simple terms, how did the DAO get hacked and funds removed from it?

A reasonable analogy I've heard is: You go to an ATM and withdraw the money. After the ATM gives you the money, you unplug the ATM before it updates your account. You plug the ATM back, withdraw ...
eth's user avatar
  • 85.7k
3 votes

In simple terms, how did the DAO get hacked and funds removed from it?

Ethcore blogpost does a good job at describing the history of the hack. Basically they knew about the vulnerability two days before the attack and fixed the function that they though was affected. ...
Visgean Skeloru's user avatar
3 votes

In simple terms, how did the DAO get hacked and funds removed from it?

The simple high level explanation would be like this; When you (as a DAO token holder) split from DAO, it creates a new child DAO and pays you back (in a transaction) your share by sending it to the ...
Kobayashi's user avatar
  • 1,255

Only top scored, non community-wiki answers of a minimum length are eligible