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

Filter by
Sorted by
Tagged with
2
votes
2answers
217 views

How does the re-entrancy guard modifier work?

Following is code for a re-entrancy guard, but not sure if I understand it properly: contract Test { using SafeMath for uint256; uint256 private counter = 1; modifier entrancyGuard() { ...
0
votes
1answer
42 views

Does reentrancy attack happens as soon as the balance in storage is modified after the withdrawal?

I just saw something like this: function sub( uint a, uint b ) internal pure returns (uint) { require(b <= a, "SUB_UNDERFLOW"); return a - b; } function withdraw(...
1
vote
1answer
21 views

Was throw part of DAO (attacked) code?

I have attached a picture related to DAO attack. I got the image from the following link A Survey on Ethereum Systems Security: Vulnerabilities, Attacks and Defenses . The image shows a code ...
1
vote
2answers
46 views

Is it possible to circumvent a require statement if the ordering of the requirements are incorrect?

Please take the following hypothetical code as an example mapping (address => uint256) public accountBalance; function deposit(uint256 amount) public { accountBalance[msg.sender] = ...
1
vote
1answer
48 views

How does this function potentially violates the Checks-Effects-Interaction pattern?

I am developing a smart contract that integrates with the DAI stable coin. In the function below, you can see that I have followed the check effects interaction pattern, so how come I still get a ...
1
vote
0answers
36 views

transfer(amount) failed even when it is not a contract

address payable receiver; receiver.transfer(amount); The receiver is NOT an contract, and the amount is only 0.4 ether, the contract is holding sufficient ether in its balance. I understood that ...
1
vote
1answer
56 views

Is it safe to do multiple payments in between locks (Reentrancy Guard)?

https://diligence.consensys.net/blog/2019/09/stop-using-soliditys-transfer-now/ provides a simple example related to using a Reentrancy Guard. Another approach to preventing reentrancy is to ...
0
votes
1answer
27 views

Is function like this one reentrant?

Got this in pseudo-code (Solidity like...) from audit of past work of person from our company, in short it seems to be withdrawing first and adding later. Maybe not a good idea, especially since it's ...
1
vote
1answer
70 views

How are transfer and send protecting against reentrancy if the gas is taken from the EOA (msg.sender)?

I guess transfer and send simply allow 2300 gas but no gas is taken from the contract? In other words if a wallet calls this function with say one million wei gas: function sending() public payable { ...
6
votes
1answer
1k views

Is transfer() still safe after the Istanbul update?

In other words, is using transfer() safe? function transfer(address contractB) public { contractB.transfer(1000); //balances[msg.sender] -= 1000; } How about using call.gas? function ...
0
votes
1answer
28 views

Transaction Timing Implications for Reentry Attacks

This is the classic reentry attack: function withdrawBalance() public { uint amountToWithdraw = userBalances[msg.sender]; (bool success, ) = msg.sender.call.value(amountToWithdraw)(""); ...
0
votes
1answer
22 views

Compliance and Violation patterns

I have downloaded the slides from the site: Compliance and Security patterns It says "No writes after calls." I can understand this concept. It’s a remedy for reentrancy problem. But it shows ...
1
vote
0answers
70 views

Reentrancy attack not working on mainnet, but working on ropsten and remix VM

I was fullfilling a reentrancy attack on a contract. I tested it in remix VM first and later on with deployed contract on ropsten testnet. Both worked well without any errors. On the mainnet it turned ...
0
votes
1answer
117 views

How does the reentrancy attack work?

Consider the following contracts contract Victim{ //... function donate() public payable { credit[msg.sender] += msg.value; } function withdraw(uint amount) public { if (credit[...
1
vote
0answers
16 views

How exactly theᴅᴀᴏ reentrancy hack was performed without having weiGiven>0 nor IsAllowed(WithdrawAddress)?

The well known ᴅᴀᴏ hack didn’t affect ether balances of theᴅᴀᴏ but balances of rewardAccount. That’s why I’m talking about the hack version which affected contract balances of theᴅᴀᴏ itself. With ...
0
votes
0answers
35 views

Revert() workflow in re-entrancy vulnerablity?

I am studying the following code contract Mutex { bool locked; modifier noReentrancy() { require(!locked); locked = true; _; locked = false; } function f(unit256 amount) public ...
0
votes
3answers
76 views

How do I attack the `Vuln` contract?

How can I steal from Vuln contract? I have made another contract to try to steal from Vuln but it always gives me an error. And I'm not sure how to send the money to my adrress. contract Vuln { ...
0
votes
0answers
28 views

Understand the `call` opcode in this contract

Hello, I am posting a quick question regarding the functionality this contract: https://etherscan.io/address/6b63ea3612dde97082aab468157950f927618d31#code From the source code, I am not even able to ...
0
votes
1answer
69 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
48 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
37 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
40 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
104 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
66 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
100 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
2answers
101 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
194 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
25 views

Transaction Nonce deterring Re-entrancy Attack?

Why doesn't the use of transaction nonce deter re-entrancy attack?
0
votes
1answer
202 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
114 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 ...
2
votes
2answers
2k 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
923 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
58 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
692 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
1k 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
261 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
435 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 ...
1
vote
2answers
272 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, especially ...
0
votes
2answers
624 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
106 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
769 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 ...
1
vote
1answer
43 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
205 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
264 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? ...
2
votes
1answer
90 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
149 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 { ...
13
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
116 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
632 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){ ...