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 Apr 28, 2024. It is now read-only.
sherlock-admin opened this issue
Oct 23, 2023
· 0 comments
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelMediumA valid Medium severity issueRewardA payout will be made for this issue
The problem arises from the _getBalance function, which retrieves the balance of the contract using balanceOf(address(this)). This can be exploited by a malicious user who sends tokens to the contract, causing the borrow function to revert due to underflow
You might argue that a user could borrow a larger amount of tokens than repay and obtain the attacker's tokens. However, the attacker can monitor the mempool, and if such a situation occurs, they can simply repay the loan they took earlier and retrieve their tokens.
Additionally, some tokens have low liquidity on Uniswap. If an attacker sends a significant number of tokens, another user may not be able to borrow a sum high enough to exceed their holdTokenBalance.
Impact
Borrowing functionality for one or all hold tokens may be unavailable.
cvetanovv
added
Duplicate
A valid issue that is a duplicate of an issue with `Has Duplicates` label
and removed
Has Duplicates
A valid issue with 1+ other issues describing the same vulnerability
labels
Oct 27, 2023
sherlock-admin
changed the title
Proud Mocha Mustang - Borrowing functionality for specific hold token may be dossed
lucifero - Borrowing functionality for specific hold token may be dossed
Oct 30, 2023
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` labelMediumA valid Medium severity issueRewardA payout will be made for this issue
lucifero
medium
Borrowing functionality for specific hold token may be dossed
Summary
The borrowing functionality for specific or all hold tokens in the smart contract may be disrupted
Vulnerability Detail
In the following code snippet borrowingCollateral is calculated by subtracting cache.holdTokenBalance from cache.borrowedAmount
The problem arises from the _getBalance function, which retrieves the balance of the contract using balanceOf(address(this)). This can be exploited by a malicious user who sends tokens to the contract, causing the borrow function to revert due to underflow
You might argue that a user could borrow a larger amount of tokens than repay and obtain the attacker's tokens. However, the attacker can monitor the mempool, and if such a situation occurs, they can simply repay the loan they took earlier and retrieve their tokens.
Additionally, some tokens have low liquidity on Uniswap. If an attacker sends a significant number of tokens, another user may not be able to borrow a sum high enough to exceed their holdTokenBalance.
Impact
Borrowing functionality for one or all hold tokens may be unavailable.
Code Snippet
https://github.com/sherlock-audit/2023-10-real-wagmi/blob/main/wagmi-leverage/contracts/LiquidityBorrowingManager.sol#L492
https://github.com/sherlock-audit/2023-10-real-wagmi/blob/main/wagmi-leverage/contracts/abstract/ApproveSwapAndPay.sol#L113-L118
Tool used
Manual Review
Recommendation
Use a more secure method to check the contract's token balance to prevent external manipulation.
Duplicate of #86
The text was updated successfully, but these errors were encountered: