Read Only Reentrancy | Hack Solidity (0.8)

  Рет қаралды 12,854

Smart Contract Programmer

Smart Contract Programmer

Күн бұрын

Пікірлер: 37
@smartcontractprogrammer
@smartcontractprogrammer 2 жыл бұрын
0:00 - Intro 0:55 - Initialize Foundry 1:16 - Code Hack contract 4:01 - Curve remove_liquidity function 8:31 - Write test 9:57 - Execute test 11:15 - Code Target contract 14:44 - Update Hack contract 17:21 - Update test 18:24 - Execute test again 19:11 - Summary Code github.com/stakewithus/defi-by-example/tree/main/read-only-reentrancy Curve STETH contract github.com/curvefi/curve-contract/blob/master/contracts/pools/steth/StableSwapSTETH.vy Take a course www.smartcontract.engineer/
@harrydare8191
@harrydare8191 2 жыл бұрын
A suggestion. You need to author a book on Solidity cause you have vast knowledge
@juanxaviervalverde
@juanxaviervalverde 2 жыл бұрын
I support the suggestion. Great mind and a helpful spirit. I'd buy your book.
@franklucas7542
@franklucas7542 2 жыл бұрын
Please make more 0.8 hack solidity videos bro, they are helping a ton!
@0xsuperman
@0xsuperman Жыл бұрын
What does 0.8 mean?
@xman25ru
@xman25ru Жыл бұрын
@@0xsuperman solidity version
@trainwreck1827
@trainwreck1827 2 жыл бұрын
This was very enlightening. Been watching for a while and this is the best.
@moayaan1911
@moayaan1911 2 жыл бұрын
New playlist started. Was waiting for this ....
@navibongo9354
@navibongo9354 2 жыл бұрын
Great vid! Love ur take on security matters. Would have loved a “how to avoid part”, but this one is fairly simple to prevent. Sry to persist, but could you make a video on bit-shifting in the v2 uniswap contract. With this im referring to the math behind the FixedPoint.uq122x122. Since your bit conversion video, i was left intrigued in how a bit shift would look with the dex values. Seeing as you can apply some logic to all bits in a 122 range for some purpose. Love your videos! Cheers
@strikeout5
@strikeout5 2 жыл бұрын
Curve should have updated all financial state prior to sending the funds out. The reason for this being possible is the callback function in the middle of a state change. tldr; Don't be in an in-between state for important variables when external contract calls are made. Otherwise, the functions in use by other contracts could be manipulated via Read Only reentrancy.
@muratctp
@muratctp 2 жыл бұрын
Just one question: why virtual price should be higher during remove_liquidity function execution?
@smartcontractprogrammer
@smartcontractprogrammer 2 жыл бұрын
1. Curve shares is removed 2. ETH is sent back, STETH is not yet sent So the imbalance in ETH - STETH is calculated as "profit". Hence virtual price is higher
@crypto_peng
@crypto_peng 2 жыл бұрын
How to avoid this attack? more like flash add-Liquidity, then instantly remove-liquidity to get the reward right?
@AllenAndersonTaylor
@AllenAndersonTaylor 2 жыл бұрын
Would you offer private tutoring? You really understand what you are doing.
@InSecWeTrust
@InSecWeTrust 2 күн бұрын
so read only happens as well because we'r not following CEI?
@weinbenderwladimir742
@weinbenderwladimir742 2 жыл бұрын
Great video! Thanks for that! How to prevent these type of attacks when designing smart contracts?
@bhok5228
@bhok5228 2 жыл бұрын
wow, impressive
@Grucha1998
@Grucha1998 2 жыл бұрын
This Channel is amazing!! How did you learn this stuff? 🤔
@smartcontractprogrammer
@smartcontractprogrammer 2 жыл бұрын
google, twitter, youtube
@juanxaviervalverde
@juanxaviervalverde 2 жыл бұрын
@@smartcontractprogrammer what youtube channels do you follow to learn?
@0xivanov
@0xivanov 2 жыл бұрын
Hey! Are you using the vim extension for vscode? :)
@smartcontractprogrammer
@smartcontractprogrammer 2 жыл бұрын
yes
@Thomasalpha-b9l
@Thomasalpha-b9l Жыл бұрын
why will the fallback function be triggered?
@smartcontractprogrammer
@smartcontractprogrammer Күн бұрын
For example calling a function that sends ETH back
@tele-anonymous
@tele-anonymous 2 жыл бұрын
Hello! What operation system do you use macOs or Linux ?
@smartcontractprogrammer
@smartcontractprogrammer 2 жыл бұрын
linux
@adk9321
@adk9321 2 жыл бұрын
What is this contract for?
@junesuprise
@junesuprise 2 жыл бұрын
why foundry and not hardhat?
@smartcontractprogrammer
@smartcontractprogrammer 2 жыл бұрын
why not?
@wonjaechoi2762
@wonjaechoi2762 Жыл бұрын
What can be a contract 'A' in the code?
@smartcontractprogrammer
@smartcontractprogrammer Күн бұрын
AMM that returns ETH
@ngjingxuan4320
@ngjingxuan4320 2 жыл бұрын
How can we prevent this hack?
@smartcontractprogrammer
@smartcontractprogrammer Күн бұрын
No general way to prevent it. From the perspective of the Target contract, there is no re-entrancy.
@raunaquepatra3966
@raunaquepatra3966 2 жыл бұрын
How to prevent it?
@ravendonly1
@ravendonly1 2 жыл бұрын
there is no way to avoid the hack here
@NishantSingh-zx3cd
@NishantSingh-zx3cd 2 жыл бұрын
if the developers reverse the sequence of loop such that the 0th element ie. ETH amount comes last in the execution of the iteration, will this vulnerability be resolved? It should look something like this: for i in xrange(N_COINS, 0, -1): value: uint256 = amounts[i] * _amount / total_supply assert value >= _min_amounts[i], "Withdrawal resulted in fewer coins than expected" amounts[i] = value if i == 0: raw_call(msg.sender, b"", value=value) else: assert ERC20(self.coins[1]).transfer(msg.sender, value) log RemoveLiquidity(msg.sender, amounts, empty(uint256[N_COINS]), total_supply - _amount) return amounts
@smartcontractprogrammer
@smartcontractprogrammer 2 жыл бұрын
i think it will
Tornado Cash Hack - How to Deploy Different Contracts At the Same Address | DeFi
8:29
How Strong Is Tape?
00:24
Stokes Twins
Рет қаралды 96 МЛН
Accessing Private Data | Hack Solidity (0.6)
17:13
Smart Contract Programmer
Рет қаралды 20 М.
Deploy Different Contracts at Same Address | Hack Solidity 0.8
15:00
Smart Contract Programmer
Рет қаралды 6 М.
Smart Contract Hacking - 0x0C - Attacking Authorization with Web3.js
14:52
Constant Sum Automated Market Maker | Solidity 0.8
32:16
Smart Contract Programmer
Рет қаралды 9 М.
Solidity | Reentrancy Attacks Everything You Need To...
3:47
EatTheBlocks
Рет қаралды 53 М.
Become a bash scripting pro - full course
36:00
CODE IS EVERYTHING
Рет қаралды 75 М.
All Rust string types explained
22:13
Let's Get Rusty
Рет қаралды 193 М.