Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [reentrant-attacks]

Questions related to "reentrancy vulnerability" or "reentrant attack", where untrusted code reenters a contract and manipulates state. http://forum.ethereum.org/discussion/1317/reentrant-contracts https://github.com/LeastAuthority/ethereum-analyses/blob/master/GasEcon.md

0
votes
1answer
24 views

Is there any Reentrancy attack in given code snippet? If yes then how can I fix it?

function withdrawForeignTokens(address _tokenContract) onlyOwner IsAuthenticate public returns (bool) { ERC223Interface token = ERC223Interface(_tokenContract); return token.transfer(...
3
votes
1answer
32 views

Understand the trending of newly-uploaded smart contracts that is considered as vulnerable

We tried to use Oyente to analyze some online contracts and drawed a diagram regarding the potentially vulnerable smart contracts ("reentrancy" bug) with respect to their creation time. So the y-...
0
votes
1answer
23 views

Is a function prone to re-entrancy attack even if I set balance to zero within the same function (example included)

Such as in this scenario, is the hackable via re-entrancy? thanks... function withdraw(uint256 money) public { if(money <= balance[msg.sender]) { (bool success, ) = msg.sender.call....
0
votes
1answer
23 views

Constantinople gas change, reentrancy possibilities

With the new reduced fee for using SSTORE for 'dirty' storage slots, is it possible to re-enter a function from a send() or transfer() and have the contract call send() or transfer() again? Or is it ...
0
votes
2answers
34 views

Will 'x.send(amount)' revert if 'x' is a contract with a fallback function which reverts?

I know that x.transfer(amount) reverts if either one of the following two scenarios takes place: There is not enough ether in the calling contract, i.e., amount > address(this).balance Variable x ...
1
vote
1answer
41 views

Compiling error when using .value() for sending money between contracts using solidity and truffle framework

Dear fellow block builders! I am new to this field and I would like to implement my first project mimicking the famous DAO attack using re-entrance. I've programmed two smart contracts - the DAO and ...
1
vote
1answer
47 views

Can emitting an event after a state change cause a reentrancy attack vulnerability?

Is the following function vulnerable to a reentrancy attack? function withdraw() public { uint amount = pendingWithdrawals[msg.sender]; // Remember to zero the pending refund before // ...
1
vote
1answer
51 views

erc-721 erc-20 solidity code check effects interaction pattern

Where can one locate a formally verified ERC20/ERC721 solidity code/template that adheres to security design patterns such as check effects interaction patterns?
1
vote
1answer
89 views

Simulating DAO recursive/reentrancy attack

Trying to simulate the attack. In my attack contract: function attack() public { target.call(bytes4(keccak256("withdraw()")),amount); } function() payable public { if (msg.sender == ...
0
votes
1answer
19 views

Transaction Nonce deterring Re-entrancy Attack?

Why doesn't the use of transaction nonce deter re-entrancy attack?
0
votes
0answers
29 views

Is there a reentrancy risk when calling a function on a known contract?

I have a series of contracts which work together, basically I split a big contract into a few smaller ones for simplicity and to make deploying easier. As such, there are several points in my code ...
0
votes
1answer
118 views

The constructor should be payable if you send value - contract sending ether to another contract throwing an error?

I'm trying to implement re-entrancy hack for my own contract. Here is a great article that explains the method: https://medium.com/@gus_tavo_guim/reentrancy-attack-on-smart-contracts-how-to-identify-...
0
votes
1answer
78 views

Potential re-entrancy vulnerability: how should I rearrange this function to avoid it?

I'm not ure why I keep getting a potential reentrancy attack vulnerability about the "publishEtherBox" function. The contract code is not complete but it should be enough to understand. Is it a bad ...
0
votes
0answers
101 views

Safe ERC223 Token with reentrancy protection?

I have this token sketched up for ERC20 compatible wallets, with the ability to send tokens to contracts via the tokenFallback receiver handler. pragma solidity ^0.4.23; library TokenMathLib { ...
0
votes
0answers
25 views

Huge amount of gas needed for deploying a simple StillBank Contract and potential re-entrancy vulnerability

I wrote these two contracts. One serves as a factory for the other. The still bank contract acts like a patreon or a streaming donation module. The factory contract is managed by the owner. The gas ...
2
votes
2answers
787 views

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

Hi was going through solidity documentation. There was some code that I was not able to understand, even after researching a lot I was not able to find some satisfactory output. The code is as under: ...
1
vote
2answers
707 views

Checking Reentrancy Vulnerability in smart contracts

According to the Ethereum Smart Contract Best Practices, race conditions can occur across multiple functions, and even multiple contracts, any solution aimed at preventing reentry will not be ...
1
vote
1answer
51 views

Differences between nameFunction.value and address.transfer

What is the difference between using nameFunction.value(n)(parameters of nameFunction) and address.transfer(10)? I know that in the case of address.transfer, I'll send the amount to the fallback ...
3
votes
2answers
609 views

Solidity msg.sender.send security problem?

As far as I understand msg.sender.send just gives enough gas to the call to do one simple logging and not more, so the contracts which does: msg.sender.send(winnings) balances[msg.sender] -= winnings ...
9
votes
1answer
908 views

Send ether reentrancy attack in reality - how could fallback function make a message call back into current contract?

Below is quoted from solidity docs: pragma solidity ^0.4.0; // THIS CONTRACT CONTAINS A BUG - DO NOT USE contract Fund { /// Mapping of ether shares of the contract. mapping(address => ...
2
votes
0answers
229 views

Where is the attack contract used for the dao attack?

I studied The DAO attack. I want to see attack contract. but I found just child dao(0x304a554a310C7e546dfe434669C62820b7D83490) Reentrant attack is needed fallback function. How can I find the ...
1
vote
2answers
292 views

Solidity: order of lines with addition and subtraction operations

After looking at many different custom token contracts I noticed that the standard of transferFrom() function is as follows: function transferFrom(address _from, address _to, uint256 _value) public ...
0
votes
1answer
205 views

Solidity: Examples of fail safe code for security

In the wiki's Security Considerations code, the Include a Fail-Safe Mode section says: While making your system fully decentralised will remove any intermediary, it might be a good idea, ...
0
votes
2answers
524 views

how can defence reentrancy attack

I studied The DAO attack. Ethereum's reentrancy attack is still work. but ethereum network also still work( Sure, compiler says "warning" ) How do you believe your contract will be safe? How ethereum ...
1
vote
1answer
90 views

Why not enforce “external calls last” policy syntactically (or in compiler) to prevent reentrant attacks?

From the docs: Write your functions in a way that, for example, calls to external functions happen after any changes to state variables in your contract so your contract is not vulnerable to a ...
1
vote
2answers
723 views

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

From the Solidity documentation I do not understand if the recently introduced address.transfer forwards all gas to the target contract or just gives a minimal gas stipend. I.e.: Would it facilitate ...
2
votes
1answer
38 views

Transaction scoped state variables

Is it possible to create a state variable that gets initialized at the start of a transaction and reset at the end? I have to create a contract that sends value (ETH) to arbitrary addresses. I can ...
2
votes
1answer
175 views

Reproducing recursive call exploit

Here's a contract that I want to attack using recursive call: contract Abstract { function foobar(); } contract B { uint stateVar; function foo(Abstract someAddress){ ...
3
votes
2answers
246 views

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

The DAO, a smart-contract on Ethereum, was vulnerable to reentrancy attacks and 3 million ETH worth $50 million was stolen from it. What are some examples of content that mentions reentrancy attacks? ...
3
votes
1answer
87 views

Reentrant attack number on 17 June 2016

This post What was the second vulnerability used in The DAO attack on 17 June 2016? say : And from the Q&A [...], each of the transactions (the first and second at least from my manual ...
7
votes
1answer
134 views

Is a suiciding contract susceptible to re-entrancy?

If my contract calls suicide() referencing a contract as the recipient of funds, and that recipient contract default function calls back into my contract, will the call succeed? contract A { ...
11
votes
1answer
2k views

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

I'm trying to get some sense from the hysteria around the attack performed to The DAO smart contract. I understand the high level explanations, but I'd like to grasp how this attack was performed. I'...
5
votes
1answer
108 views

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

Haven't tested it out but I think in theory this could work. It might work somehing like this: An attacker first writes a lot of data to storage so there is data to be deleted. Using .send() in the ...
6
votes
1answer
608 views

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

If my dapp sends ether to another address via the send() method is it not vulnerable for the recursive call attack due to the limited amount of gas of 21000? Or should I still take precautions?
8
votes
1answer
2k views

Callstack attack

If my contract has a payout function like this address bossAddress; address employeeAddress; uint256 bossSalary; uint256 employeeSalary; function payout (){ if (msg.sender==bossAddress){ ...
7
votes
2answers
1k views

How was the recursion created that lead to theDAO hack?

I understand that if theDAO contract has a withdrawal function that sends money to contract X - contract X can be malicious and use the fallback function to call the withdrawal function again. However ...
5
votes
4answers
525 views

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

How did the DAO get hacked? Can someone explain in simple terms?
19
votes
3answers
4k views

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

Can anyone explain that how the DAO attack happened? Vitalik Buterin explained here that it was performed by splitting a DAO from the main DAO but calling the split function recursively. We know that ...
46
votes
3answers
7k views

What is a recursive calling vulnerability?

What is a recursive calling vulnerability exactly? When creating smart contracts, DAOs or DAPPs, what measures can I take to ensure I am not vulnerable?
14
votes
1answer
2k views

How much computation can be done in a fallback function?

Simply sending Ether to a contract, will run the contract's code. In Solidity, this code maps to what it calls the fallback function. How much work can be done in a fallback function?