_depositIBT uses the _convertIBTsToShares to calculate the amount of shares to be minted for input _ibts. The shares here is correctly rounded down which can be seen below;
However, the _ptRate which is calculated from _getPTandIBTRates passes the false parameter, rounding down the new _ptRate. Since the _ptRate is involved in share calculations and is inversely proportional to the shares we mint, the final shares its mints will actually be higher.
Check out the _convertIBTsToSharesPreview implementation which rightly rounds up the ptRate to evaluate shares amount.
Lines of code
https://github.com/code-423n4/2024-02-spectra/blob/383202d0b84985122fe1ba53cfbbb68f18ba3986/src/tokens/PrincipalToken.sol#L684
Vulnerability details
Impact
_depositIBT
uses the_convertIBTsToShares
to calculate the amount of shares to be minted for input_ibts
. The shares here is correctly rounded down which can be seen below;https://github.com/code-423n4/2024-02-spectra/blob/383202d0b84985122fe1ba53cfbbb68f18ba3986/src/tokens/PrincipalToken.sol#L691
However, the
_ptRate
which is calculated from_getPTandIBTRates
passes thefalse
parameter, rounding down the new_ptRate
. Since the_ptRate
is involved in share calculations and is inversely proportional to theshares
we mint, the finalshares
its mints will actually be higher.Check out the
_convertIBTsToSharesPreview
implementation which rightly rounds up theptRate
to evaluateshares
amount.Proof of Concept
https://github.com/code-423n4/2024-02-spectra/blob/383202d0b84985122fe1ba53cfbbb68f18ba3986/src/tokens/PrincipalToken.sol#L702
Tools Used
Manual
Recommended Mitigation Steps
If this is not intentional, round up the
ptRate
the same way it has been done for_convertIBTsToSharesPreview
function.Assessed type
Other