Closed c4-submissions closed 1 year ago
Scaling down on usdy.transfer(msg.sender, usdyAmount / BPS_DENOMINATOR) would do it just right.
raymondfam marked the issue as low quality report
raymondfam marked the issue as primary issue
raymondfam marked the issue as duplicate of #46
kirk-baird marked the issue as unsatisfactory: Invalid
Lines of code
https://github.com/code-423n4/2023-09-ondo/blob/main/contracts/usdy/rUSDY.sol#L436
Vulnerability details
Impact
BPS_DENOMINATOR in the rUSDY.sol contract is an important variable used to scale up usdy amount -> shares as noted in it comment description but it is only used to scale up when minting shares but not scaled down before subtracting it from total shares and burning it, this would cause fund math calculation related errors and possible inflation of shares
Proof of Concept
https://github.com/code-423n4/2023-09-ondo/blob/main/contracts/usdy/rUSDY.sol#L436
The function above shows how the _USDy amouth is scaled up before minting shares however no scale down was done before burning shares as would be shown below https://github.com/code-423n4/2023-09-ondo/blob/main/contracts/usdy/rUSDY.sol#L449-L453
https://github.com/code-423n4/2023-09-ondo/blob/main/contracts/usdy/rUSDY.sol#L588
As seen from the two functions above, at no point in time in the unwrap(...) or _burnShares(...) functions was a scale down down with BPS_DENOMINATOR before deducting it from total shares
Tools Used
Manual Review
Recommended Mitigation Steps
Mitigation depends on Sponsor preference, one way could be to ensure a scale down of the shares with BPS_DENOMINATOR before burning the shares in unwrap function call, another way could be to mint the shares without up scaling it in the wrap function call as provided below. multiplication of _USDYAmount with BPS_DENOMINATOR should simply be replaced with just _USDYAmount
or
Assessed type
Error