Closed c4-bot-5 closed 8 months ago
gzeon-c4 marked the issue as sufficient quality report
gzeon-c4 marked the issue as primary issue
yanisepfl (sponsor) disputed
If the ERC20 asset does not implement the decimals()
method (which is optional indeed) then our PT initialization would revert, which is the intended behavior.
Therefore, we do not consider this to be an issue and dispute it.
JustDravee marked the issue as unsatisfactory: Invalid
Lines of code
https://github.com/code-423n4/2024-02-spectra/blob/main/src/tokens/PrincipalToken.sol#L142 https://github.com/code-423n4/2024-02-spectra/blob/main/src/libraries/PrincipalTokenUtil.sol#L137-L148
Vulnerability details
Description
In the documentation it is explained that:
And:
The EIP-4626 explains that
But the underlying ERC20
decimals()
function is optional. So a compliant ERC4626 vault could return a decimal but the underlying asset not. The protocol should work with an underlying ERC20 withoutdecimals()
function since the protocol is expected to interact with any ERC4626 compliant vault.But on the
intialize
function, it calls thedecimals()
function of the underlying:In the case where there is no
decimals
function it reverts.Moreover, even in the case where the
decimals
function of the underlying asset returns a value which is not between 6 and 18, the conversion in the Ray.sol library could revert or not be as precise as wanted (the library's description says "Library for number conversions from decimals between 6 and 18 to 27 decimals (ray)").Tools Used
Manual review
Recommended Mitigation Steps
There are 2 differents solutions.
The first solution is to change documentation to warn developers. They need to know that :
The second solution is to consider a default value for assets with no decimals. For example, the IBT's decimals can be used in this case. In the constructor:
Before pushing this modification, it should make sure that it is not missleading for users and then to cause bad behaviors.
Moreover, a full logic may be implemented to make sure if _assetDecimals is not between 6 and 18, it does not cause troubles.
Assessed type
ERC20