-
Notifications
You must be signed in to change notification settings - Fork 5
bin2chen - borrow() maliciously let others to enter market #76
Comments
I also don't think this is a valid finding. How is this not a low or a recommendation? There is no clear impact here, especially because the user whose account was used to enter the market would have no obligations to the market whatsoever. Plus, he can just exit the market when he likes |
Escalate Users can simply exit the market via exitMarket function until they don't have any debt at that market. |
You've created a valid escalation! To remove the escalation from consideration: Delete your comment. You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final. |
I marked this issue as valid because a borrower cannot realize that an attacker has entered a market on his behalf so if a liquidation happens later, the borrower will have its assets seized from the recently entered market when it shouldn't be possible. |
My comment still stands and I agree with @MehdiKarimi81. If a malicious user enters a market on my behalf, I can just exit the market whenever possible. Secondly, if a user doesn't have funds in the market, such market, even though he's entered, will not amount to any value and won't be considered for liquidation. Finally, if indeed the victim is in the market, during deposit, he would have been automatically entered and if the attacker entered the market before the victim's deposit, the victim's deposit still legitimises the market entered by the attacker. There is no real harm done here |
A user can deposit assets in a market to earn from lending them but he can exit the market instantly so that the assets he deposited are not considered in the liquidity calculations. When an attacker enters a market on a user's behalf, all those assets are at risk of seizure if the borrower is liquidated, which shouldn't be like that. |
At the risk of the debating this further, I'll just allow whoever is in charge as Head of judging resolved this. There is no risk to a user who is in a market with empty collateral. It's the same as saying that a fixed rate pool LP will get nothing if there's no backup borrow. That's how the protocol was designed. At best. This is a low/informational |
why the liquidator shouldn't be able to liquidate those funds? if other markets have not enough liquidity then liquidating from this market seems rational |
Check out my submission, this explains very well how this affects the user and why they can't simply exit the market:
|
PS I'd request the judge to consider this if that's the case |
However, there is no loss of funds and the liquidator only uses other assets for liquidation, despite it may be unexpected for the borrower but no loss of funds happened, it only affects user experience and according to sherlock docs : Issues that cause minor inconvenience to users where there is no material loss of funds are not considered valid |
When the borrower is liquidated and some funds that should not count as collateral are seized, that's clearly a loss of funds for the borrower. |
This issue can be Medium. It breaks core contract functionality. A malicious user should not force another user to enter the market. Аll the duplicates have found the root cause of the issue, and for that, the duplicates should remain. I also find the @santipu03 and @0xA5DF comments reasonable, which further increases the severity of this issue to Medium. Planning to reject the escalation and leave the issue as is. |
The protocol team fixed this issue in the following PRs/commits: |
Result: |
Escalations have been resolved successfully! Escalation status:
|
The Lead Senior Watson signed off on the fix. |
bin2chen
medium
borrow() maliciously let others to enter market
Summary
After
borrow()
is executed successfully,borrower
will automatically enter the market.This method performs a security check to determine if the
msg.sender
allowance is sufficient to avoid malicious operations.But it doesn't limit the borrow number !=0, so anyone can execute without an allowance.
This causes the permission check to fail and maliciously allows others to enter the market
Vulnerability Detail
borrow()
is executed by callingauditor.checkBorrow()
.checkBorrow()
will cause theborrower
to automatically enter the market.however, this method does not determine that
assets
cannot be 0. If the user specifiesassets=0
then the security check for allowances can be skipped, and theborrower
will enter the market after the method is executed successfullyPOC
The following code demonstrates that no allowances are needed to let the
borrower
enter the marketadd to
Market.t.sol
Impact
The current protocol makes a strict distinction between enter market or not.
A user can be a simple
LP
to a market and not participate in borrowing or collateralization, which is then protected and cannot be used as aseize market
for liquidation purposes.At the same time, if the user does not enter the market, then the user can access the assets as they wish without constraints.
And so on.
If any person can maliciously allow others to enter the market to break the rules.
For example, maliciously liquidating
seize
a protected marketCode Snippet
https://github.com/sherlock-audit/2024-04-interest-rate-model/blob/main/protocol/contracts/Market.sol#L167
Tool used
Manual Review
Recommendation
function borrow( uint256 assets, address receiver, address borrower ) external whenNotPaused whenNotFrozen returns (uint256 borrowShares) { + if (assets == 0) revert ZeroBorrow(); spendAllowance(borrower, assets);
The text was updated successfully, but these errors were encountered: