People often ask me "How did you learn how to hack?" The answer: by reading. This page is a collection of the blog posts and other articles that I have accumulated over the years of my journey. Enjoy!
skim
function is used for a recovery mechanism in the case of the reserves storage (uint112) failing. If the difference between the current balance of the pair (balanceOf
on the ERC20 token) and the reserves are different, the sender of the request gets the difference. Although this can save the contract, this is a very dangerous function to have in.balanceOf
function is controlled the true balance of the user, _largeTotal
, and _totalSupply
. If any of these change, the balanceOf
call will also change.transfer
will update the totalSupply
whenever a transfer occurs. The problem is that there is no validation on whether the sender and recipient are the same! This means that the _totalSupply
can be inflated indefinitely. balanceOf
function relies upon the totalSupply
, it will increase the result! This means that the cost of the reserves and the amount that the tokens has is different. Using the skim
function allows a user to withdraw funds now. skim
using the contract address over and over again. Since the totalSupply
is updated over and over again and this changes the price, the funds of the Uniswap pool can be stolen using the skim. Overall, a very interesting attack exploiting how Uniswap works in conjunction with a bad vulnerability within the ERC20 token.