Read-Only Reentrancy Explained | Solidity Security (0.8)

Added:

Reentrancy Basics
Setup and Interfaces
Exploit Strategy
Price Discrepancy
Deploy and Test
Build Target Contract
Write Vulnerability
Integrate Exploit
Execute and Compare
Result and Impact

Reentrancy Basics

0:00
Playing Section
  • 1

    Explains classic reentrancy: contract calls target, target calls back before first call ends.

  • 2

    Introduces read-only variant: state is read during a pending external call.

  • 3

    Sets up simulation on Curve pool using Foundry, not a live attack.

Understanding of classic (state-changing) reentrancy vulnerabilities and standard mitigations like the Checks-Effects-Interactions pattern and ReentrancyGuards.
Basic mechanics of Automated Market Makers (AMMs) and how decentralized finance (DeFi) protocols utilize them as on-chain price oracles.
Proficiency in Solidity 0.8 development, specifically around contract-to-contract interactions, external calls, and state management.
Familiarity with the Foundry development and testing framework, including writing unit tests and executing mainnet fork simulations.
Implementation of advanced mitigation strategies for read-only reentrancy, such as utilizing lock-aware external checks or integrating resilient Chainlink TWAP oracles.
Analysis of prominent real-world read-only reentrancy exploits, such as the Euler Finance, Sentiment, or Balancer pool vulnerabilities.
Exploration of complex cross-contract and cross-protocol reentrancy vectors where execution flow spans multiple distinct DeFi projects.
Using automated vulnerability detection tools (like Slither) and writing property-based fuzz tests in Foundry to identify price manipulation risks.
14K views377likes19:55@smartcontractprogrammerOriginal Release: 2022-10-30

A read-only reentrancy attack exploits the fact that when a contract calls another contract (like Curve's remove_liquidity), the receiving contract's receive() function executes before the original call finishes, allowing an attacker to read inflated or stale state values (such as virtual price) during the intermediate execution phase, which can be leveraged to manipulate reward calculations or other dependent logic in target contracts.