Skip to content
Business logic Audit finding Intermediate

Protocol doesn’t properly handle Aave Pool changes

The protocol allows the owner to change the Aave pool address but does not revoke token approvals from the old pool or grant approvals to the new pool. As a result, after a pool change, supply and withdraw operations for existing Aave-strategy deposit pools fail, locking funds and halting deposits.

ZanyBonzy Follow with anchabadze

Originally disclosed on Code4rena

Submitted by ZanyBonzy, also found by anchabadze

https://github.com/code-423n4/2025-08-morpheus/blob/d275e9035b7e703efe26cdee6543e78f452774bb/contracts/capital-protocol/Distributor.sol#L135-L141

https://github.com/code-423n4/2025-08-morpheus/blob/d275e9035b7e703efe26cdee6543e78f452774bb/contracts/capital-protocol/Distributor.sol#L226-L237

https://github.com/code-423n4/2025-08-morpheus/blob/d275e9035b7e703efe26cdee6543e78f452774bb/contracts/capital-protocol/Distributor.sol#L285-L328

Finding description and impact

setAavePool is used to set new aave pool address, presumably to handle pool changes, upgrades, or migration situations.

    function setAavePool(address value_) public onlyOwner {
        require(value_ != address(0), "DR: invalid Aave pool address");

        aavePool = value_;//<<===

        emit AavePoolSet(value_);
    }

There are two issues with this however.

  1. Aave recommends executing calls to pools dynamically, i.e querying PoolAddressProvider for the current pool address. The protocol doesn’t do this, opting to allow the owner to set the pool address whenever it is required, leaving a window between which the pool in use will be deprecated, leading to DOS issues until a new pool is set.
  2. The more serious issue, is the missing approval revocation for old pool and granting for the new one. This is because max token approvals are only set once when deposit pools are added in addDepositPool(). After updating aavePool, supply, withdraw, and withdrawYield calls for existing Aave-strategy deposit pools fail due to missing approvals for the new pool. The isDepositTokenAdded mapping prevents re-adding the same token to re-approve, locking funds or halting deposits.

As a result, the protocol is stuck in a state where, the current aave pool is deprecated and unusable, and the new pool that is set cannot be used due to missing approvals for the new pool, locking down operations.

        address aToken_ = address(0);
        if (strategy_ == Strategy.AAVE) {
            (aToken_, , ) = AaveIPoolDataProvider(aavePoolDataProvider).getReserveTokensAddresses(token_);

            IERC20(token_).safeApprove(aavePool, type(uint256).max);//<<===
            IERC20(aToken_).approve(aavePool, type(uint256).max);//<<===
        }

        DepositPool memory depositPool_ = DepositPool(token_, chainLinkPath_, 0, 0, 0, strategy_, aToken_, true);

Aave pools have been designed to be updated or migrated since V1, and major pool addresses have been updated in the past (e.g., during major version upgrades like V2 to V3 or pool migrations), so this is a realistic scenario, especially over the long term.

Recommended Mitigation Steps

Set immutable poolAddressProvider instead and query it everytime aavePool functions need to be accessed. Approve the queried address to spend the needed amount of tokens for each transaction.

Proof of Concept

We add the test below to Distributor.test.ts

  describe('Bug - setAavePool approval issue', () => {
    const maxUint256 = 2n**256n - 1n;
    beforeEach(async () => {
      await chainLinkDataConsumerMock.setAnswer(dp1Info.chainLinkPath, wei(1));
      await distributor.addDepositPool(
        dp1Info.rewardPoolId,
        dp1Info.depositPool,
        dp1Info.depositToken,
        dp1Info.chainLinkPath,
        dp1Info.strategy,
      );
      await dp1Info.depositToken.mint(BOB, wei(1000));
      await dp1Info.depositToken.connect(BOB).approve(dp1Info.depositPool, wei(1000));
      await distributor.setRewardPoolLastCalculatedTimestamp(publicRewardPoolId, 1);
    });

    it('should fail supply after changing aavePool due to missing approvals', async () => {
      // Initial supply works with original aavePool
      await dp1Info.depositPool.connect(BOB).supply(publicRewardPoolId, wei(100));
      let dp1 = await distributor.depositPools(publicRewardPoolId, dp1Info.depositPool);
      expect(dp1.deposited).to.eq(wei(100));
      expect(await dp1Info.aToken.balanceOf(distributor)).to.eq(wei(100));

      // Change aavePool
      const newAavePool = await deployAavePoolMock(aavePoolDataProviderMock);
      await distributor.setAavePool(newAavePool);

      // Attempt to supply again, should fail due to missing approval
      await expect(
        dp1Info.depositPool.connect(BOB).supply(publicRewardPoolId, wei(50))
      ).to.be.revertedWith('ERC20: insufficient allowance');

      // Verify no new deposits
      dp1 = await distributor.depositPools(publicRewardPoolId, dp1Info.depositPool);
      expect(dp1.deposited).to.eq(wei(100));
      expect(await dp1Info.aToken.balanceOf(distributor)).to.eq(wei(100));

      // Attempt to withdraw, should also fail
      await expect(
        dp1Info.depositPool.connect(BOB).withdraw(publicRewardPoolId, wei(50))
      ).to.be.revertedWith('ERC20: insufficient allowance');
    });

    it('should show old pool still has approvals while new pool has none', async () => {
      // Check that original Aave pool has approvals
      const originalAllowance = await dp1Info.depositToken.allowance(distributor, aavePoolMock);
      expect(originalAllowance).to.eq(maxUint256);

      // Update to new Aave pool
      const newAavePool = await deployAavePoolMock(aavePoolDataProviderMock);
      await distributor.setAavePool(newAavePool);

      // New pool has no approvals
      const newAllowance = await dp1Info.depositToken.allowance(distributor, newAavePool);
      expect(newAllowance).to.eq(0);

      // Old pool still has approvals (potential security concern)
      const oldAllowance = await dp1Info.depositToken.allowance(distributor, aavePoolMock);
      expect(oldAllowance).to.eq(maxUint256);
    });
  });

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

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

Likely the contract only sets token approvals when a deposit pool is first added and never updates them when the Aave pool address is changed, so the new pool has no allowance and the old pool keeps its unlimited allowance.

Impact

After a pool change, supply and withdraw operations for existing Aave-strategy deposit pools fail, locking funds and halting deposits until approvals are fixed.

What the attacker needed

Owner changes the Aave pool address; existing Aave-strategy deposit pools

The fix

The protocol should set an immutable pool address provider and query it each time the Aave pool is needed, approving the queried address per transaction.

How it was found

  1. Add a deposit pool with the Aave strategy, which sets maximum token approvals to the current Aave pool.
  2. Supply tokens successfully using the original Aave pool.
  3. Call setAavePool to change the Aave pool address to a new one.
  4. Attempt to supply more tokens; the transaction reverts with an insufficient allowance error.
  5. Attempt to withdraw tokens; the transaction also reverts with an insufficient allowance error.
  6. Check allowances: the old pool still has maximum allowance while the new pool has zero.

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.

This is a smart contract that lets people deposit tokens, which are then supplied to an external lending pool (Aave) to earn yield. The contract must give that external pool permission to move its tokens, called an 'approval'. When the owner switches to a new Aave pool, the old permission is not removed and the new pool never gets permission, so deposits and withdrawals stop working.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by ZanyBonzy

View all

9 more disclosed reports, best first.

More from Morpheus

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.