Hi guys, i have a question.
Is recursive reentrancy possible when contract A sends ether to contract B via .transfer() and then Contract B call contract A again recursively (before contract A function is completed) to drain contract A balances? I have read the solidity docs and there is stated that ether sent via send() and transfer() functions can rely on 2300 gas only. I have written POC and when i call contract A recursively on ether recived in contract B, it only works for 1 iteration, if there are more than 1 iterations tx reverts.
Sep 5, 2023, 8:58 AM
as you said
transfer is capped to 2300 gas
transfer is capped to 2300 gas
Sep 5, 2023, 9:38 AM
so no recursive reentrancy possibility in that case, right?
Sep 5, 2023, 9:38 AM
not at the same level of .call()
Sep 5, 2023, 9:39 AM
my fear is that contract A changes balances state variable after the .transfer() thats why i am asking, but whatever i do i was only able to do 1 iteration, so the balances was also changed
Sep 5, 2023, 9:40 AM
can you share a screenshot
Sep 5, 2023, 9:40 AM
yeah sec
Sep 5, 2023, 9:40 AM
reentrancy can be avoid easily
just need to write good code
just need to write good code
Sep 5, 2023, 9:41 AM
this is from contract A
this is from contract B
Sep 5, 2023, 9:43 AM
burn before transfering eth
Sep 5, 2023, 9:45 AM
yeah, will do that but is the reentrancy possible and drain the available eth in contract A? according to solidity docs as far i understood no?
Sep 5, 2023, 9:46 AM
depends on how many ETH you send at each iteration
Sep 5, 2023, 9:57 AM