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
1 vote
2 answers
44 views

Can ERC-20 token transfers have re-entrancy?

I understand that re-entrance attack can happened when you send ETH, because of fallback() function. But in ERC20 transfer there is no call for fallback, so I wonder if there's a way to make re-...
user avatar
  • 11
0 votes
0 answers
26 views

Should I not use re-entrancy guard if multiple people might be calling the function at same time?

I went through the openzeppelin's implementation of re-entrancy guard. https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/security/ReentrancyGuard.sol I find the state ...
user avatar
  • 62
1 vote
0 answers
25 views

Contract scoped memory variables in solidity

By my research I haven't found a way to have contract scoped memory variables. My objective is to have a mutex like the one described here https://www.blunderingcode.com/writing-secure-solidity/ but ...
user avatar
  • 113
0 votes
1 answer
204 views

How to implement a withdraw function using call{value} and divide between accounts

This best practice recommends using something like: address private constant WALLET_A = 0xabcdabcdacbdbabskbkashda; function withdraw() public onlyOwner { (bool success, ) = WALLET_A.call{value: ...
user avatar
0 votes
0 answers
45 views

Reentrancy attack exercise does not work

I’m trying to solve the reentrancy exercise from the Ethernaut project - https://ethernaut.openzeppelin.com/level/0xe6BA07257a9321e755184FB2F995e0600E78c16D. I created a hacking contract but it does ...
user avatar
  • 105
0 votes
0 answers
34 views

withdraw in Re-entrancy attack throws (Although one or more Error Occurred [out of gas] Contract Execution Completed)

I am a programming novice and was trying Re-entrancy attack on my own contract, but whenever I call withdraw, it makes a lot of internal trxs and each one of them fails with "out of gas", ...
user avatar
  • 1
1 vote
1 answer
56 views

Meaning of fowarding gas to the fallback function and its relationship with the reentrancy attack

I am reading https://solidity-by-example.org/fallback/ and the difference between send, transfer and call in <address>.send vs <address>.transfer best practice usage?. Based on my current ...
user avatar
0 votes
1 answer
59 views

call{value:} results in an internal transaction — so why is it recommended over tranfer()?

Working on a contract that should allow users to withdraw funds. I've read a number of sources saying that call{value:} (formerly call.value()) should be used over transfer() , e.g., https://...
user avatar
1 vote
1 answer
186 views

(ERC721) Is my mint() function guaranteed to mint consecutive tokenIDs for each user who calls it?

It is great to see a supportive community that could potentially help me out. I hope my question (as a beginner blockchain dev) is not too basic. I have the following mint() function (users can call ...
user avatar
  • 11
0 votes
1 answer
176 views

Re-Entrancy attack solidity ^0.8.10

I'm trying to execute the reentrancy attack from [this website][1]; all functions work except function attack(). compiler 0.8.10 EtherStore funded with Ether sending 1 Ether by executing attack() --&...
user avatar
  • 1
1 vote
2 answers
193 views

Can't reproduce the reentrancy bug

I'm trying to reproduce the reentrancy bug with solc 0.8.0: I have two contracts, // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract Reentrancy { uint256 public withdrawalLimit = 1 ...
user avatar
  • 147
1 vote
3 answers
715 views

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

I am trying to write a ERC-721 NFT minting contract and I am noticing that a lot of users are guarding against reentrancy attack. I was wondering why(and if) is this needed. An example of a contracts ...
user avatar
  • 15
1 vote
1 answer
45 views

Running out of gas before draining target completely using reentrancy exploit [closed]

Recreated the reentrancy exploit (somewhat) successfully on ganache. Unable to drain the target completely owing to out-of-gas error occuring midway. Hence have currently limited the drain. Though a ...
user avatar
0 votes
1 answer
36 views

checks-Effects-interactions and the invariants

Kindly check the following link for the paper (section 2.1.5): SmartCheck paper From the paper: Use the “checks – effects – interactions“ pattern: (a)first check the invariants, (b)then update the ...
user avatar
  • 1,185
1 vote
1 answer
160 views

HALF of a transaction reverted

I am reading an interesting honeypot posted years ago. But I was confused by how the honeypot contract is implemented. More specifically, take this transaction as an example. As we can see, during ...
user avatar
  • 111
2 votes
1 answer
321 views

Is ERC777 and Uniswap drama resolved?

Reference https://github.com/OpenZeppelin/exploit-uniswap Apparently, an years ago, there was reentrancy exploit on uniswap that was caused by ERC777 functionality: "Technically, the main logic ...
user avatar
  • 315
0 votes
0 answers
48 views

Solidity re-entrancy attacks and how to guard against them

I'm trying to understand re-entrancy attacks. Is tip1() below at risk of a re-entrancy attack (if the fallback function of the miner's contract invokes tip1() itself)? And if so, is tip2() safe? ...
user avatar
  • 11
1 vote
2 answers
1k views

Slither Tool Error On Contract That Inherit From Openzeppeling

Hey Guys Hi ALl ! *I'm trying to use SLITHER (analizy tool ) but when i try to use it on a contract what inherit from Openzeppelin it give me this error(photo) Error: Source "@openzeppelin/...
user avatar
0 votes
0 answers
180 views

The transaction has been reverted to the initial state

I have been testing the script for reentrancy attack in remix, but every time I run it reverts the transaction. I did it in two different accounts, one for the etherstore's contract(deploying) and ...
user avatar
0 votes
0 answers
5 views

Have Numerous Store Contracts, Want to Push to Get Funds, What are the Risks

Basically I have many "storefront" contracts (they are personalized to a vendor) that collect Eth/tokens. Currently the way the vendor gets their payout (and I get my cut) is us calling a ...
user avatar
  • 122
0 votes
1 answer
63 views

Reentrancy Attack -How to do it on this sell function? [closed]

Hey there guys how are u , can someone help me on this ? I want to do a REENTRANCY on this Dex , how can i change the code on sell function to stell ETH ,when somebody wanna sell theyr token throught ...
user avatar
0 votes
1 answer
305 views

Can safeTransfer cause reentrancy?

so I'm learning about reentrancy. I understand that external calls can result in reentrancy. Recently, I have started learning about Openzeppelin libraries, and got to know about safeERC20, which is a ...
user avatar
2 votes
1 answer
79 views

SMT Checker : Unexpected " BMC: Insufficient funds happens here"

I was using the SMT Solidity Model Checker, and I Don't understand why I have a :" BMC: Insufficient funds happens here". My code is quite simple, I just wanted to check if the Model Checker ...
user avatar
3 votes
1 answer
89 views

Executing reentrancy on Truffle Console: attacker not stealing 5 ether , why only 2 reentrant calls?

I am doing the example provided at: JustDev I have parameterized the withdraw method. Victim SC is: pragma solidity ^0.5.8; contract Victim{ address owner; constructor() public{ owner = ...
user avatar
  • 1,185
5 votes
1 answer
909 views

Re-entrancy attack explanation and possible fix for specific NFT token - hashmasks

One popular recent NFT project - Hashmasks - Tweeted that some coder called 'samczsun' uncovered a possible re-entrancy attack in their mint function which would have allowed to mint more than the ...
user avatar
1 vote
1 answer
273 views

openzeppelin ReentrancyGuard Constructor

I am trying to use the openzeppelin ReentrancyGuard contract within my ERC721 Token smart contract. Since this ReentrancyGuard contract has a constructor, I am required to declare it in my contract. ...
user avatar
  • 281
1 vote
3 answers
157 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 ...
user avatar
  • 1,274
0 votes
0 answers
29 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....
user avatar
  • 1,185
0 votes
1 answer
28 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[...
user avatar
  • 1,185
1 vote
1 answer
305 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 ...
user avatar
  • 113
2 votes
0 answers
127 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, ...
user avatar
  • 73
0 votes
1 answer
2k 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 ...
user avatar
  • 3
1 vote
1 answer
166 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: ...
user avatar
  • 13
0 votes
0 answers
33 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 ...
user avatar
  • 23
5 votes
2 answers
3k 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() { ...
user avatar
  • 557
0 votes
1 answer
109 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(...
user avatar
1 vote
1 answer
45 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 ...
user avatar
  • 1,185
1 vote
2 answers
83 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] = ...
user avatar
  • 503
1 vote
1 answer
193 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 ...
user avatar
1 vote
0 answers
123 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 ...
user avatar
  • 816
1 vote
1 answer
268 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 ...
user avatar
  • 7,599
0 votes
1 answer
90 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 ...
user avatar
1 vote
1 answer
986 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 { ...
user avatar
16 votes
2 answers
7k 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 ...
user avatar
0 votes
1 answer
76 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)(""); ...
user avatar
0 votes
1 answer
28 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 ...
user avatar
  • 1,185
2 votes
1 answer
278 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 ...
user avatar
  • 31
0 votes
1 answer
580 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[...
user avatar
  • 101
1 vote
0 answers
32 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 ...
user avatar
0 votes
0 answers
54 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 ...
user avatar
  • 101