code-423n4 / 2021-04-marginswap-findings

1 stars 0 forks source link

An erroneous constructor's argument could block the withdrawReward #33

Open code423n4 opened 3 years ago

code423n4 commented 3 years ago

Email address

simomonica1997@gmail.com

Handle

s1m0

Eth address

0x9b3E9e3E4a174d59279FC7cd268e035992412384

Vulnerability details

The constructor of IncentiveDistribution https://github.com/code-423n4/marginswap/blob/main/contracts/IncentiveDistribution.sol#L32 take as argument the address of MFI token but it doesn't check that is != address(0). Not worth an issue alone but IncentiveDistribution imports IERC20.sol and it never use it.

Impact

In case the address(0) is passed as arguement the withdrawReward woul fail https://github.com/code-423n4/marginswap/blob/main/contracts/IncentiveDistribution.sol#L261 and due to the fact that MFI is immutable the only solution would be to redeploy the contract meanwhile losing trust from the users.

Proof of concept

Deploy IncentiveDistribution with 0 as _MFI argument and then call withdrawReward.

Tools used

Manual analysis

Recommended mitigation steps

Check _MFI != address(0)