Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shield - Attacker can force a user to enter a market #227

Closed
sherlock-admin3 opened this issue May 4, 2024 · 0 comments
Closed

Shield - Attacker can force a user to enter a market #227

sherlock-admin3 opened this issue May 4, 2024 · 0 comments
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A valid Medium severity issue Reward A payout will be made for this issue

Comments

@sherlock-admin3
Copy link
Contributor

sherlock-admin3 commented May 4, 2024

Shield

medium

Attacker can force a user to enter a market

Summary

Vulnerability Detail

  • Whenever a user borrows (even a zero borrow) they are entered into the market
  • There's no check on borrow() to verify that the borrow amount isn't zero.
  • Since borrowing a zero amount doesn't require any allowance, anybody can call borrow() with zero amount using any receiver as borrower
  • This leads to the fact that anybody can force anybody to enter into any market

Consider the following scenario:

  • Bob has assets in the USDC, and DAI market
  • They approved Alice to borrow on their behalf on the ETH market
  • They entered the USDC market, but not the DAI market
  • Alice now wants to use Bob's DAI collateral to take a loan, so she forces him to enter the market with a zero-borrow
  • Alice took a loan using collateral she wasn't supposed to use according to the protocol's design, causing a loss of assets to Bob

Impact

Users are forced to enter market and use their assets as collateral.
This allows users who're approved to borrow on other markets to borrow on their behalf using assets they didn't intend to use as collateral.

Code Snippet

No zero check here:
https://github.com/sherlock-audit/2024-04-interest-rate-model/blob/main/protocol/contracts/Market.sol#L140-L145

PoC:
Add the following to protocol/test/Market.t.sol

import { console2} from "forge-std/console2.sol";

  function testForceEnter_POC() external {
    address bob = address(0xbab);
    uint marketsBefore = auditor.accountMarkets(bob);
    market.borrow(0, address(this), bob);
    uint marketsAfter = auditor.accountMarkets(bob);

    console2.log("before:", marketsBefore);
    console2.log("after:", marketsAfter);
  }

Ouptut:

Ran 1 test for test/Market.t.sol:MarketTest
[PASS] testForceEnter_POC() (gas: 162091)
Logs:
  before 0
  after 1

Tool used

Manual Review

Recommendation

Revert on zero borrows

Duplicate of #76

@github-actions github-actions bot closed this as completed May 8, 2024
@github-actions github-actions bot added Medium A valid Medium severity issue Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label labels May 8, 2024
@sherlock-admin3 sherlock-admin3 changed the title Sticky Myrtle Griffin - Attacker can force a user to enter a market Shield - Attacker can force a user to enter a market May 17, 2024
@sherlock-admin3 sherlock-admin3 added the Reward A payout will be made for this issue label May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A valid Medium severity issue Reward A payout will be made for this issue
Projects
None yet
Development

No branches or pull requests

1 participant