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 3, 2023. It is now read-only.
Bauer - Does not consider that the difference in precision between loan token and collateral token may cause the user will be not able to borrow tokens.
#48
Closed
github-actionsbot opened this issue
Mar 10, 2023
· 0 comments
github-actionsbot opened this issue
Mar 10, 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
Does not consider that the difference in precision between loan token and collateral token may cause the user will be not able to borrow tokens.
Summary
The protocol does not consider that the difference in precision between loan token and collateral token , if the loan token is WETH ( the decimal of WETH is 18) and collateral token is USDT (the decimal of WETH is 6). user will be not able to borrow loan tokens.
Vulnerability Detail
The protocol allows user to add collateral tokens and borrow loan tokens. When user call the function borrow() to borrow loan tokens ,the protocol will calculate user collateral ratio and the ratio should less than _currentCollateralRatioMantissa. The userCollateralRatioMantissa is calculated according to this formula uint userCollateralRatioMantissa = userDebt * 1e18 / collateralBalanceOf[msg.sender];. However, if the loan token is WETH ( the decimal of WETH is 18) and collateral token is USDT (the decimal of WETH is 6). The user collateral ratio will be userCollateralRatioMantissa = x*1e18*1e18/y1e6. The decimal of result will be 30 and it is greater than _currentCollateralRatioMantissa (the decimals is 18). User will be not able to complete the borrowing.
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
Bauer
high
Does not consider that the difference in precision between loan token and collateral token may cause the user will be not able to borrow tokens.
Summary
The protocol does not consider that the difference in precision between loan token and collateral token , if the loan token is WETH ( the decimal of WETH is 18) and collateral token is USDT (the decimal of WETH is 6). user will be not able to borrow loan tokens.
Vulnerability Detail
The protocol allows user to add collateral tokens and borrow loan tokens. When user call the function
borrow()
to borrow loan tokens ,the protocol will calculate user collateral ratio and the ratio should less than_currentCollateralRatioMantissa
. TheuserCollateralRatioMantissa
is calculated according to this formulauint userCollateralRatioMantissa = userDebt * 1e18 / collateralBalanceOf[msg.sender];
. However, if the loan token is WETH ( the decimal of WETH is 18) and collateral token is USDT (the decimal of WETH is 6). The user collateral ratio will beuserCollateralRatioMantissa = x*1e18*1e18/y1e6
. The decimal of result will be 30 and it is greater than_currentCollateralRatioMantissa
(the decimals is 18). User will be not able to complete the borrowing.Impact
Users will be not able to complete the borrowing.
Code Snippet
https://github.com/sherlock-audit/2023-02-surge/blob/main/surge-protocol-v1/src/Pool.sol#L455-L498
Tool used
Manual Review
Recommendation
Depending on the precision of each Token, the ratio is calculated dynamically
Duplicate of #122
The text was updated successfully, but these errors were encountered: