You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 17, 2023. It is now read-only.
sherlock-admin opened this issue
Mar 13, 2023
· 0 comments
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelHighA valid High severity issueRewardA payout will be made for this issue
Collateral ratio calculation is incorrect if collateralToken isn't in 18 decimals
Summary
Some calculations in the contracts are incorrect if the collateral token has less or more than 18 decimals.
Since the protocol wants to add other yield bearing tokens in the future, this will cause large losses of funds if the token doesn't have 18 decimals.
Vulnerability Detail
The function _computeCR() in TauMath.sol will give an incorrect collateral ratio if the collateral token doesn't have 18 decimals.
For example, if the collateral token XYZ has 8 decimals and the price feed has 8 decimals, the debt is 1000 TAU, and the collateral is 1000 XYZ and the price is 1 XYZ = 1 TAU, then
The value expected is 1e18 but the calculation gives 1e8. This will cause the collateral ratio to be much smaller than expected leading to early liquidations of users.
If decimals is bigger than 18, then the collateral ratio will be much larger than expected, allowing users to take undercollateralized loan and steal TAU from the contract.
Impact
Loss of user funds due to collateral ratio larger or smaller than expected.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelHighA valid High severity issueRewardA payout will be made for this issue
Bahurum
high
Collateral ratio calculation is incorrect if
collateralToken
isn't in 18 decimalsSummary
Some calculations in the contracts are incorrect if the collateral token has less or more than 18 decimals.
Since the protocol wants to add other yield bearing tokens in the future, this will cause large losses of funds if the token doesn't have 18 decimals.
Vulnerability Detail
The function
_computeCR()
inTauMath.sol
will give an incorrect collateral ratio if the collateral token doesn't have 18 decimals.For example, if the collateral token XYZ has 8 decimals and the price feed has 8 decimals, the debt is 1000 TAU, and the collateral is 1000 XYZ and the price is 1 XYZ = 1 TAU, then
The value expected is 1e18 but the calculation gives 1e8. This will cause the collateral ratio to be much smaller than expected leading to early liquidations of users.
If decimals is bigger than 18, then the collateral ratio will be much larger than expected, allowing users to take undercollateralized loan and steal TAU from the contract.
Impact
Loss of user funds due to collateral ratio larger or smaller than expected.
Code Snippet
https://github.com/sherlock-audit/2023-03-taurus/blob/main/taurus-contracts/contracts/Libs/TauMath.sol#L18-L19
https://github.com/sherlock-audit/2023-03-taurus/blob/main/taurus-contracts/contracts/Vault/BaseVault.sol#L406
Tool used
Manual Review
Recommendation
In
TauMath.sol
:In
BaseVault:_calcLiquidation
:Duplicate of #35
The text was updated successfully, but these errors were encountered: