Introduction
- Welcome to the next stage of your Reentrancy journey!
- This lesson covers the solution to the Reentrancy Fundamentals: Defend Lab.
Prerequisites
Code Solution: DIFF View
In the below DIFF, you'll witness the differences between the original
Vulnerable.sol
and the updated Vulnerable.sol
that implements the Checks-Effects-Interactions pattern.
Tip
- Green highlights: Correspond to additions.
- Red highlights: Correspond to removals.
Code Solution
Tip
- To maximize viewing space, click the icon within the bottom left corner
Explanation
Challenge: Attacker.sol should NOT be able to steal all ETH from Vulnerable.sol- Marker
1
: As thisif
statement is checking a condition, it is classified as a Check. - Marker
2
: As this statement is affecting the contract state, it's considered an Effect. - Marker
3
: As this statement is interacting with an external contract, it's considered an Interaction. - By following the Checks-Effects-Interactions pattern, the Reentrancy vulnerability was mitigated.
Slither Output: DIFF View
Tip
- Green highlights: Correspond to additions.
- Red highlights: Correspond to removals.
In the
slither
output DIFF (above), you'll witness the differences between the original Vulnerable.sol
and the updated Vulnerable.sol
that implements the Checks-Effects-Interactions pattern. Notice that slither
's reentrancy findings no longer appear.
Disclosures
Warning: