New strategy can not work due to insufficient allowance
When a new strategy is added to MultiStrategyVault, it is not approved to spend the vault's asset. Any function that calls the new strategy's deploy() may revert, causing a denial of service for the vault.
Submitted by 0xpiken, also found by 0xlemon, klau5, and shaflow2
When a new strategy is added through MultiStrategy#addStrategy(), it was not approved to spend the asset in MultiStrategyVault. Any functions that call newStrategy#deploy() may revert and result in MultiStrategyVault being DoS’ed.
Proof of Concept
MultiStrategyVault is used to manage multiple investment strategies. A new strategy can be added through MultiStrategy#addStrategy():
107: function addStrategy(IStrategy strategy) external onlyRole(VAULT_MANAGER_ROLE) {
108: if (address(strategy) == address(0)) revert InvalidStrategy();
109: _strategies.push(strategy);
110: _weights.push(0);
111: emit AddStrategy(address(strategy));
112: }
However, the new strategy was not approved to spend the asset in MultiStrategyVault, resulting MultiStrategyVault being DoS’ed.
Copy below codes to VaultMultiStrategy.ts and run npm run test:
it.only('Add Strategy - no allowance', async () => {
const { vault, usdc, owner, otherAccount } = await loadFixture(deployMultiStrategyVaultFixture);
//@audit-info deploy a new strategy
const Strategy = await ethers.getContractFactory('StrategySupplyAAVEv3');
const strategy = await Strategy.deploy(
owner.address,
await usdc.getAddress(),
otherAccount.address,
);
await strategy.waitForDeployment();
//@audit-info add the new strategy to vault
await vault.addStrategy(await strategy.getAddress());
//@audit-info the new strategy has been added
expect(await vault.strategies()).to.include(await strategy.getAddress());
expect(await vault.asset()).to.equal(await usdc.getAddress());
//@audit-info however, the new strategy was not approved to spend asset of vault
expect(await usdc.allowance(vault.target, strategy.target)).to.equal(0);
});
As we can see, the new strategy has zero allowance.
Recommended mitigation steps
The new strategy should be approved with max allowance when added:
function addStrategy(IStrategy strategy) external onlyRole(VAULT_MANAGER_ROLE) {
if (address(strategy) == address(0)) revert InvalidStrategy();
_strategies.push(strategy);
_weights.push(0);
+ IERC20(strategy.asset()).approve(address(strategy), type(uint256).max);
emit AddStrategy(address(strategy));
}
chefkenji (BakerFi) confirmed
Status: Mitigation confirmed. Full details in reports from 0xlemon and shaflow2.
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 addStrategy function does not approve the new strategy to spend the vault's asset.
Impact
Functions that call the new strategy's deploy() may revert, causing a denial of service for the vault.
What the attacker needed
Vault manager role
The fix
The addStrategy function should approve the new strategy to spend the vault's asset with maximum allowance.
How it was found
- Deploy a new strategy contract.
- Call addStrategy on the vault with the new strategy's address.
- Observe that the strategy is added but the vault's asset allowance for the strategy is 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.
A vault holds money and lets different strategies invest it. For a strategy to take money from the vault, the vault must first give it permission, called an allowance. The vault forgot to give this permission when adding a new strategy, so the strategy cannot take the money and any attempt to use it fails.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.