First Flight #18: T-Swap

First Flight #18
Beginner FriendlyDeFiFoundry
100 EXP
View results
Submission Details
Severity: low
Invalid

`PoolFactory()::constructor()` must have a zero check, to avoid pool creation with `address(0)`

Summary

PoolFactory contract can be deployed with weth address as 0x0. so, all the TSwapPool's will be created with zero address hence failing the protocol.
Additionally have a similar check for PoolFactory()::CreatePool() function to have a zero check.

Vulnerability Details

Place below code in PoolFactoryTest.t.sol and run - forge test --mt testZeroWethAddress

function testZeroWethAddress() public {
factory = new PoolFactory(address(0));
TSwapPool pool = TSwapPool(factory.createPool(address(tokenA)));
assertEq(address(pool.getWeth()), address(0));
vm.expectRevert();
pool.deposit(1 ether, 1 ether, 1 ether, uint64(block.timestamp));
}

Impact

Since, i_wethToken is immutable, the address can't be overwritten at later point and all the contracts must be deployed again for protocol to function.

Tools Used

Foundry

Recommendations

Make below code changes in PoolFactory.sol

+ error PoolFactory__ZeroAddress();
constructor(address wethToken) {
+ if(wethToken == address(0)){
+ revert PoolFactory__ZeroAddress();
}
i_wethToken = wethToken;
}
Updates

Appeal created

inallhonesty Lead Judge 11 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.