Skip to content
This repository has been archived by the owner on Sep 17, 2023. It is now read-only.

GimelSec - The decimals of collateral may different from 1e18, causing the user to borrow more than the real amount that can be borrowed. #159

Closed
sherlock-admin opened this issue Mar 13, 2023 · 0 comments
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label High A valid High severity issue Reward A payout will be made for this issue

Comments

@sherlock-admin
Copy link
Contributor

sherlock-admin commented Mar 13, 2023

GimelSec

high

The decimals of collateral may different from 1e18, causing the user to borrow more than the real amount that can be borrowed.

Summary

The decimals of collateral may different from 1e18, causing the user to borrow more than the real amount that can be borrowed.

Vulnerability Detail

The decimals of Collateral are not always 1e18. If we have a collateral token with 1e27 decimals, we will get a wrong collateral ratio.

Suppose we have 120 collateral tokens which are worth $120.

In _computeCR(): (_coll * _price * Constants.PRECISION) / (_debt * 10 ** priceDecimals)

  • _coll: 120 * 1e27
  • _price: 1 * 1e18, which means a collateral worth $1
  • priceDecimals: 1e18
  • _debt: 100 * 1e18, the max debt due to 120% collateral ratio

We get: (120*1e27 * 1*1e18 * 1e18) / (100*1e18 * 10**18) = 1.2 * 1e27, which is 120000000000% rather than 120%.

Impact

Users can borrow more than the real amount that can be borrowed.

Code Snippet

https://github.com/sherlock-audit/2023-03-taurus/blob/main/taurus-contracts/contracts/Libs/TauMath.sol#L18

Tool used

Manual Review

Recommendation

Handle the decimals of collateral in _computeCR.

Duplicate of #35

@github-actions github-actions bot added High A valid High severity issue Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label labels Mar 21, 2023
@sherlock-admin sherlock-admin added the Reward A payout will be made for this issue label Apr 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label High A valid High severity issue Reward A payout will be made for this issue
Projects
None yet
Development

No branches or pull requests

1 participant