Open code423n4 opened 2 years ago
Amazing catch, because the contract bytecode has been change, the init hash will be different.
While the bug seems trivial, it's impact is a total bricking of all swapping functionality as the Library will cause all Periphery Contracts to call to the wrong addresses.
Because of the impact, I agree with High Severity
Lines of code
https://github.com/Plex-Engineer/zeroswap/blob/03507a80322112f4f3c723fc68bed0f138702836/contracts/uniswapv2/libraries/UniswapV2Library.sol#L20-L28
Vulnerability details
The
init code hash
inUniswapV2Library.pairFor()
should be updated since the code ofUniswapV2Pair
has been changed. Otherwise, thepair
address calculated will be wrong, most likely non-existing address.There are many other functions and other contracts across the codebase, including
UniswapV2Oracle
,UniswapV2Router02
, andSushiRoll
, that rely on theUniswapV2Library.pairFor()
function for the address of the pair, with theUniswapV2Library.pairFor()
returning a wrong and non-existing address, these functions and contracts will malfunction.Recommendation
Update the init code hash from
hex'e18a34eb0e04b04f7a0ac29a6e80748dca96319b42c54d679cb821dca90c6303'
to the value ofUniswapV2Factory.pairCodeHash()
.