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

cergyk - BBLeverage::buyCollateral Malicious operator can abuse _allowedBorrow approval on Big bang market #31

Closed
sherlock-admin4 opened this issue Mar 15, 2024 · 1 comment
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 Sponsor Disputed The sponsor disputed this issue's validity Will Fix The sponsor confirmed this issue will be fixed

Comments

@sherlock-admin4
Copy link
Contributor

sherlock-admin4 commented Mar 15, 2024

cergyk

high

BBLeverage::buyCollateral Malicious operator can abuse _allowedBorrow approval on Big bang market

Summary

buyCollateral enables a user to deleverage a borrow position on a BigBang market. However in the case an operator uses an user allowance to carry the operation on the user behalf, he can abuse the approval to make the user transfer an arbitrary amount (within the limits of a yieldbox approval to the market).

Vulnerability Detail

We can see that the _allowedBorrow is checked at the end of buyCollateral

However it fails to account that the operator controls slippage incurred here

And thus even though _allowedBorrow is checked, an arbitrarily big amount can be pulled here provided the user has an unlimited approval of the yield box contract to the big bang market.

It is worth to be noted that unlimited approvals are common among users wanting to save on gas.

It is also worth to be noted that the malicious operator has to be approved for some amount of borrow by the user because of this condition

Scenario

Alice has approved operator Bob for 1 wei of borrow on ETH BigBang market.

Bob can call buyCollateral on behalf of Alice, specifying an arbitrary calldata_.supplyAmount which will use Alice's unlimited approval of yieldBox usdo asset here, then swap it using getCollateral and ensure the amountOut to be 1 wei (can use a malicious token on the swap path).

As a result all of the checks have passed, but Alice is drained of her usdo

Impact

allowedBorrow allowance can be abused by a malicious operator to steal tokens from users.

Code Snippet

Tool used

Manual Review

Recommendation

Add an additional check against an oracle to not incur excessive slippage in the getCollateral swap

Alternatively, consider to spend lending allowance when pulling usdo instead of spending borrow allowance when providing collateral

Duplicate of #140

@cryptotechmaker
Copy link

Medium; Pre-conditioned by the user making the exploit possible

@sherlock-admin2 sherlock-admin2 added Sponsor Disputed The sponsor disputed this issue's validity Will Fix The sponsor confirmed this issue will be fixed labels Mar 18, 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 Mar 20, 2024
@nevillehuang nevillehuang reopened this Mar 28, 2024
@nevillehuang nevillehuang added Has Duplicates A valid issue with 1+ other issues describing the same vulnerability Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label and removed Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Has Duplicates A valid issue with 1+ other issues describing the same vulnerability labels Mar 28, 2024
@sherlock-admin3 sherlock-admin3 changed the title Modern Mandarin Wasp - BBLeverage::buyCollateral Malicious operator can abuse _allowedBorrow approval on Big bang market cergyk - BBLeverage::buyCollateral Malicious operator can abuse _allowedBorrow approval on Big bang market Mar 31, 2024
@sherlock-admin3 sherlock-admin3 added the Reward A payout will be made for this issue label Mar 31, 2024
@Evert0x Evert0x added High A valid High severity issue and removed Medium A valid Medium severity issue labels Apr 18, 2024
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 Sponsor Disputed The sponsor disputed this issue's validity Will Fix The sponsor confirmed this issue will be fixed
Projects
None yet
Development

No branches or pull requests

6 participants