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

Ignite - The claimDefaulted function might revert if there is no allowance of OHM tokens from the Clearinghouse to the MINTR contract. #188

Closed
sherlock-admin opened this issue Aug 28, 2023 · 0 comments
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

Comments

@sherlock-admin
Copy link
Contributor

sherlock-admin commented Aug 28, 2023

Ignite

high

The claimDefaulted function might revert if there is no allowance of OHM tokens from the Clearinghouse to the MINTR contract.

Summary

The MINTR.burnOhm() function requires allowances ohm tokens from the owner first to burn ohm. Thus, the Clearinghouse.claimDefaulted() function may revert at line 245 since there is no allowance ohm token from Clearinghouse to the MINTR contract.

Vulnerability Detail

When someone calls the Clearinghouse.claimDefaulted() function to default the loan, this will unstake and burn the collateral of the defaulted loans.

function claimDefaulted(address[] calldata coolers_, uint256[] calldata loans_) external {
    ...
    // Unstake and burn the collateral of the defaulted loans.
    gOHM.approve(address(staking), totalCollateral - keeperRewards);
    MINTR.burnOhm(address(this), staking.unstake(address(this), totalCollateral - keeperRewards, false, false));
}

However, at line 245, the MINTR.burnOhm() function needs to approve ohm tokens from the owner before MINTR burns the owner's ohm token.

MINTR: https://github.com/OlympusDAO/olympus-v3/blob/19236eb1c02464df8fb79c7b59b7195d7511b338/src/modules/MINTR/OlympusMinter.sol#L50-L61

function burnOhm(address from_, uint256 amount_)
    external
    override
    permissioned
    onlyWhileActive
{
    if (amount_ == 0) revert MINTR_ZeroAmount();

    ohm.burnFrom(from_, amount_);

    emit Burn(msg.sender, from_, amount_);
}

OHM Token: https://etherscan.io/token/0x64aa3364f17a4d01c6f1751fd97c2bd3d7e7f1d5

function burnFrom(address account_, uint256 amount_) external override {
    _burnFrom(account_, amount_);
}

function _burnFrom(address account_, uint256 amount_) internal {
    uint256 decreasedAllowance_ = allowance(account_, msg.sender).sub(amount_, "ERC20: burn amount exceeds allowance");

    _approve(account_, msg.sender, decreasedAllowance_);
    _burn(account_, amount_);
}

As a result, the Clearinghouse.claimDefaulted() function may revert with the error string "ERC20: burn amount exceeds allowance".

Reference address: https://docs.olympusdao.finance/main/technical/addresses

Impact

The user may not be able to default the loan on behalf of the Clearinghouse and the collateral will be stuck.

Code Snippet

https://github.com/sherlock-audit/2023-08-cooler/blob/main/Cooler/src/Clearinghouse.sol#L244

Tool used

Manual Review

Recommendation

Add the ohm variable address as a relevant contract in Clearinghouse.
Increase the ohm token to burn from the Clearinghouse contract to the MINTR contract and pass the burn if the ohm token to burn is 0 since MINTR.burnOhm() will revert in this case.

    // Unstake and burn the collateral of the defaulted loans.
    gOHM.approve(address(staking), totalCollateral - keeperRewards);
+   uint256 ohmToBurn = staking.unstake(address(this), totalCollateral - keeperRewards, false, false);
+   if (ohmToBurn > 0) {
+       ohm.increaseAllowance(address(MINTR), ohmToBurn);
-       MINTR.burnOhm(address(this), staking.unstake(address(this), totalCollateral - keeperRewards, false, false));
+       MINTR.burnOhm(address(this), ohmToBurn);
+   }
}

Duplicate of #176

@github-actions github-actions bot closed this as completed Sep 1, 2023
@github-actions github-actions bot added High A valid High severity issue Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label labels Sep 1, 2023
@sherlock-admin2 sherlock-admin2 changed the title Rough Garnet Ape - The claimDefaulted function might revert if there is no allowance of OHM tokens from the Clearinghouse to the MINTR contract. Ignite - The claimDefaulted function might revert if there is no allowance of OHM tokens from the Clearinghouse to the MINTR contract. Sep 12, 2023
@sherlock-admin2 sherlock-admin2 added the Reward A payout will be made for this issue label Sep 12, 2023
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
Projects
None yet
Development

No branches or pull requests

2 participants