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
0
votes
3answers
45 views

Do view functions cause reentrancy vulnerabulity?

It's well known that calling an external function before changing something in the contract causes a security problem called "reentrancy vulnerability". Does calling an external function ...
0
votes
0answers
24 views

Can't understand the problem with the code

I am reading the following tutorial. Tutorial What is the problem with the following code: function withdraw(uint amount) public { require(balances[msg.sender] >= amount); balances[msg....
0
votes
1answer
15 views

Denial of Service(DoS) and withdraw.pendingReturns[msg.sender]=0;

I am trying to understand the role of : withdraw.pendingReturns[msg.sender]=0; in detecting denial of Service (DoS) vulnerability. The following paper VeriSolid says that: withdraw.pendingReturns[...
1
vote
1answer
28 views

Reentrancy protection against multiple entries at once

I'm concerned about the security of the Reentrancy pattern that we can use in Solidity to prevent from calling multiple times a same function at the same time. This protection is nicely implemented ...
2
votes
0answers
88 views

Fail to Reproduce reentrancy in private chain but success in remix VM

I ran same victim and attack codes in remix VM, and private chain connected with metamask and remix. But, the attack successed in remix vm not in private. I inserted flag to mark which step is wrong, ...
0
votes
1answer
45 views

How should 'fallback' function be defined if we transact using 'call' method? [duplicate]

i came to know that 'call' method is better for transacting, since all gas is transferred and could withstand reentrancy attack.. but how should we define fallback function for 'call' method? using ...
1
vote
1answer
51 views

Different proxy code to upgrade smart contract and reentrancy attacks

I am trying to upgrade smart contract in ethereum. I found that proxy pattern can help me with this. In the openzeppelin docs, I should add the following code in fallback function in my contract: ...
0
votes
0answers
24 views

Please look over my contract for re-entrancy

I know the random number generator isn't secure and is susceptible to manipulation from miners and any advice on the method to generate random numbers will be appreciated. However, the reason I'm ...
2
votes
2answers
360 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
47 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
26 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
52 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
81 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
48 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
101 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
30 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
158 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 { ...
7
votes
2answers
2k 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
36 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
23 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 ...
2
votes
1answer
105 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
230 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
20 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
38 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
93 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
29 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
87 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
50 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
43 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
182 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
71 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
124 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
125 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
220 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
26 views

Transaction Nonce deterring Re-entrancy Attack?

Why doesn't the use of transaction nonce deter re-entrancy attack?
0
votes
1answer
232 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
120 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
3k 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
1k 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
714 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
267 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
522 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
303 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
652 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
107 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
779 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
47 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 ...