Skip to content
Access control Audit finding Intermediate

`Borrowing::redeemYields` debits `ABOND` from `msg.sender` but redeems to `user` using `ABOND.State` data from `user`

The redeemYields function debits ABOND from msg.sender but calculates the redemption amount using the user parameter's ABOND state, allowing an attacker to redeem yields from another user's position without debiting that user. This lets the attacker drain ETH backing ABOND from the external protocol.

0x73696d616f Follow with RampageAudit, kenzo123 and 5 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-11-autonomint-judging/issues/271

Found by

0x73696d616f, RampageAudit, kenzo123, santiellena, super_jack, t.aksoy, tjonair, volodya

Summary

Borrowing::redeemYields debits ABOND from msg.sender (which updates its state), but uses the information of the user passed to calculate the amount to be withdrawn from the external protocol to send to the user. This allows an attacker to have one address with ABOND recently purchased (msg.sender), redeem yield to user using user ABOND.State data (ethBacked and cumulativeRate). As the debit occurs to msg.sender address, the attacker can repeatedly buy ABOND in an external market and redeem yields from user without debiting from user.

Root Cause

The Borrowing::redeemYields function, receives as parameters address user, uint128 aBondAmount and calls the BorrowLib::redeemYields function:

First, the function incorrectly checks if the user has enough ABOND balance when it should check if msg.sender enough balance: BorrowLib.sol#L990-L992

Solidity
State memory userState = abond.userStates(user);
// check user have enough abond
if (aBondAmount > userState.aBondBalance) revert IBorrowing.Borrow_InsufficientBalance();

Then, it calculates the amount of USDa that has to burn, and the amount to send to user for the liquidation earnings of the protocol.

Finally, the Treasury::withdrawFromExternalProtocol function is called with user and abondAmount as parameters: BorrowLib.sol#L1028-L1029

Solidity
// withdraw eth from ext protocol
uint256 withdrawAmount = treasury.withdrawFromExternalProtocol(user,aBondAmount);

Going through the Treasury::withdrawFromExternalProtocol: Treasury.sol#L283-L296

Solidity
    function withdrawFromExternalProtocol(
        address user,
        uint128 aBondAmount
    ) external onlyCoreContracts returns (uint256) {
        if (user == address(0)) revert Treasury_ZeroAddress();
        
        // Withdraw from external protocols
        uint256 redeemAmount = withdrawFromIonicByUser(user, aBondAmount);
        // Send the ETH to user
        (bool sent, ) = payable(user).call{value: redeemAmount}("");
        // check the transfer is successfull or not
        require(sent, "Failed to send Ether");
        return redeemAmount;
    }

The redeemAmount of ETH got in Treasury::withdrawFromIonicByUser is sent to the user: Treasury.sol#L703-L724

Solidity
    function withdrawFromIonicByUser(
        address user,
        uint128 aBondAmount
    ) internal nonReentrant returns (uint256) {
        uint256 currentExchangeRate = ionic.exchangeRateCurrent();
        uint256 currentCumulativeRate = _calculateCumulativeRate(currentExchangeRate, Protocol.Ionic);
        
        State memory userState = abond.userStates(user);
        uint128 depositedAmount = (aBondAmount * userState.ethBacked) / PRECISION;
        uint256 normalizedAmount = (depositedAmount * CUMULATIVE_PRECISION) / userState.cumulativeRate;
        
        //withdraw amount
        uint256 amount = (currentCumulativeRate * normalizedAmount) / CUMULATIVE_PRECISION;
        // withdraw from ionic
        ionic.redeemUnderlying(amount);
        
        protocolDeposit[Protocol.Ionic].totalCreditedTokens = ionic.balanceOf(address(this));
        protocolDeposit[Protocol.Ionic].exchangeRate = currentExchangeRate;
        // convert weth to eth
        WETH.withdraw(amount);
        return amount;
    }

As it can be seen, the amont is calculated with userState data of the user. That data is stored in the ABOND contract. After this redeem, the ethBacked of the user should be zero because it is withdraw.

However, the account that gets its ABOND debited and thus its ethBacked and cumulativeRate data set to zero is the msg.sender, and not the user. BorrowLib.sol#L1032

Solidity
bool success = abond.burnFromUser(msg.sender, aBondAmount);

Abond_Token.sol#L172-L184

Solidity
    function burnFromUser(
        address to,
        uint256 amount
    ) public onlyBorrowingContract returns (bool) {
        //get the state
        State memory state = userStates[to];
        // update the state
        state = Colors._debit(state, uint128(amount));
        userStates[to] = state;
        // burn abond
        burnFrom(to, amount);
        return true;
    }

Colors.sol#L41-L60

Solidity
    function _debit(
        State memory _fromState,
        uint128 _amount
    ) internal pure returns(State memory) {
    
        uint128 balance = _fromState.aBondBalance;
        
        // check user has sufficient balance
        require(balance >= _amount,"InsufficientBalance");
        
        // update user abond balance
        _fromState.aBondBalance = balance - _amount;
        
        // after debit, if abond balance is zero, update cr and eth backed as 0
        if(_fromState.aBondBalance == 0){
            _fromState.cumulativeRate = 0;
            _fromState.ethBacked = 0;
        }
        return _fromState;
    }

As can be seen, the address that gets its state modified is msg.sender and not user.

Internal pre-conditions

The following conditions are not a restriction, with just time and funds it can be done.

  • An old position of ABOND with ethBacked.
  • Another account owning some ABOND (acquired in the protocol or purchased in an external market).

External pre-conditions

None

Attack Path

  • The attacker deposits a big amount of ETH in the Borrowing contract.
  • The attacker withdraws that deposit receiving ABOND (which is backed by ETH deposited in another protocol)
  • The attacker wait until the cumulativeRate is significant.
  • The attacker purchases with another address some ABOND
  • The attacker calls Borrowing::redeemYields with the user parameter set as the first address that deposited in step 1.

Impact

  • The ETH deposited in the external protocol that backs ABOND can be completely drained.
  • ABOND value will fall to zero as there won't be ETH to redeem it for.

PoC

None

Mitigation

Enforce msg.sender to be equal to user.

The original report as published on Sherlock, by 0x73696d616f. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The function checks and debits ABOND from msg.sender but uses the user parameter's ABOND state to calculate the redemption amount, so the debit and the calculation refer to different accounts.

Impact

The ETH deposited in the external protocol that backs ABOND can be completely drained, and ABOND value will fall to zero as there won't be ETH to redeem it for.

What the attacker needed

An old ABOND position with ethBacked; Another account owning some ABOND

The fix

The function should enforce that msg.sender is equal to user.

How it was found

  1. The attacker deposits a large amount of ETH in the Borrowing contract.
  2. The attacker withdraws that deposit, receiving ABOND backed by ETH in another protocol.
  3. The attacker waits until the cumulativeRate is significant.
  4. The attacker purchases some ABOND with another address.
  5. The attacker calls Borrowing::redeemYields with the user parameter set to the first address from step 1.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

ABOND is a token that represents a deposit, and its state includes how much ETH backs it. The redeem function mistakenly uses the state of the address you specify as 'user' to decide how much ETH to send, but it subtracts the ABOND from your own address. So you can take someone else's yield without reducing their balance.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by 0x73696d616f

View all

172 more disclosed reports, best first.

More from Autonomint Colored Dollar V1

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.