Closed code423n4 closed 1 year ago
This will most likely be QA:
I also believe the tx will revert immediately so funds will not be at risk
L
GalloDaSballo changed the severity to QA (Quality Assurance)
GainsGoblin marked the issue as sponsor confirmed
1L from Dups
2L
GalloDaSballo marked the issue as grade-c
Lines of code
https://github.com/code-423n4/2022-12-tigris/blob/588c84b7bb354d20cbca6034544c4faa46e6a80e/contracts/StableVault.sol#L67
Vulnerability details
Impact
_output = _amount/10**(18-IERC20Mintable(_token).decimals())
line. If theIERC20Mintable(_token).decimals()
function returns 0, this line will attempt to divide by 0, which could cause the code to throw an error or behave in an unintended manner.Proof of Concept
`_output = _amount/10**(18-IERC20Mintable(_token).decimals())
Tools Used
manually
Recommended Mitigation Steps
To address the potential divide-by-zero error in this code, it would be recommended to add a check to ensure that the value returned by
IERC20Mintable(_token).decimals()
is not 0 before attempting to divide by it. This could be done by adding anif
statement to check the value, and either returning an error or using a different calculation method if the value is 0. For example: