A proof of concept demonstrating an attack that occurred on yETH.
The attack exploited unsafe math operations in Pool.vy:1274. The original code used unsafe_div, unsafe_sub, and unsafe_mul which bypass Vyper's built-in overflow/underflow checks.
Fix: Using safe math (standard arithmetic operators) instead of unsafe math causes the attack to revert. See the commented code in src/Pool.vy at line 1272-1276 and test_attack in test/Hack.t.sol.
-
Clone the repository
git clone https://github.com/johnnyonline/yETH-hack.git cd yETH-hack -
Set up virtual environment
uv venv source .venv/bin/activate # On Windows: .venv\Scripts\activate deactivate # To deactivate the venv
-
Install dependencies
# Install all dependencies uv syncNote: This project uses uv for faster dependency installation. If you don't have uv installed, you can install it with
pip install uvor follow the installation instructions. -
Environment setup
cp .env.example .env # Edit .env with your API keys and configuration
Build:
forge bTest:
forge t --mt test_attack -vv