Closed code423n4 closed 2 years ago
https://github.com/code-423n4/2022-07-fractional/blob/8f2697ae727c60c93ea47276f8fa128369abfe51/src/modules/Migration.sol#L175-L214 https://github.com/code-423n4/2022-07-fractional/blob/8f2697ae727c60c93ea47276f8fa128369abfe51/src/modules/Migration.sol#L430-L482 https://github.com/code-423n4/2022-07-fractional/blob/8f2697ae727c60c93ea47276f8fa128369abfe51/src/modules/Migration.sol#L520-L529
If you got all the fractions you got a div 0 when _calculateContribution in the commit and migrateFractions functions
div 0
_calculateContribution
commit
migrateFractions
Manual Review
Add if that returns _totalEth if _totalFractions == _lastTotalSupply
_totalEth
_totalFractions == _lastTotalSupply
function _calculateTotal( uint256 _scalar, uint256 _lastTotalSupply, uint256 _totalEth, uint256 _totalFractions ) private pure returns (uint256) { if (_totalFractions == _lastTotalSupply) { return _totalEth; } return (_totalEth * _scalar) / (_scalar - ((_totalFractions * _scalar) / _lastTotalSupply)); }
Duplicate of #155
Lines of code
https://github.com/code-423n4/2022-07-fractional/blob/8f2697ae727c60c93ea47276f8fa128369abfe51/src/modules/Migration.sol#L175-L214 https://github.com/code-423n4/2022-07-fractional/blob/8f2697ae727c60c93ea47276f8fa128369abfe51/src/modules/Migration.sol#L430-L482 https://github.com/code-423n4/2022-07-fractional/blob/8f2697ae727c60c93ea47276f8fa128369abfe51/src/modules/Migration.sol#L520-L529
Vulnerability details
Impact
If you got all the fractions you got a
div 0
when_calculateContribution
in thecommit
andmigrateFractions
functionsTools Used
Manual Review
Recommended Mitigation Steps
Add if that returns
_totalEth
if_totalFractions == _lastTotalSupply