Closed c4-bot-6 closed 8 months ago
gzeon-c4 marked the issue as insufficient quality report
gzeon-c4 marked the issue as duplicate of #5
JustDravee marked the issue as unsatisfactory: Invalid
JustDravee marked the issue as unsatisfactory: Invalid
Lines of code
https://github.com/code-423n4/2024-02-spectra/blob/383202d0b84985122fe1ba53cfbbb68f18ba3986/src/tokens/PrincipalToken.sol#L680-L693 https://github.com/code-423n4/2024-02-spectra/blob/383202d0b84985122fe1ba53cfbbb68f18ba3986/src/tokens/PrincipalToken.sol#L680-L693
Vulnerability details
Impact
Mishandling decimals allow attackers to slowly drain additional assets over multiple deposits and withdrawals. This could extract substantial unintended value long-term.
Because in
_convertIBTsToShares
not using sufficient precision for decimal math: _convertIBTsToSharesThe truncation happens here when the widow is discarded.
Proof of Concept
The
_convertIBTsToShares
math can lose precision and enable a slow drain attack stealing user funds over repeated deposits/withdrawals._convertIBTsToShares
does:shares = ibts / ptRate
From truncating the result:
Scenario
This succinctly conveys the risk of losing precision in
_convertIBTsToShares
.Tools Used
Manual review
Recommended Mitigation Steps
Instead of storing
ptRate
with the implied 27 decimals, consider explicitly making it an integer with more decimal places (e.g., 36 decimals). This would reduce the amount discarded during truncation.Assessed type
Decimal