Skip to content
Business logic Audit finding Intermediate

Updating the feeManger on config will cause desync between bank and vaults

The bank contract caches the fee manager address at initialisation, while vaults always read the current fee manager from config. If the fee manager is updated in config, the bank and vaults use different fee managers, causing inconsistent fees for users.

0x52 Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-05-blueberry-judging/issues/32

Found by

0x52

Summary

When the bank is initialized it caches the current config.feeManager. This is problematic since feeManger can be updated in config. Since it is precached the address in bank will not be updated leading to a desync between contracts the always pull the freshest value for feeManger and bank.

Vulnerability Detail

https://github.com/sherlock-audit/2023-05-blueberry/blob/main/blueberry-core/contracts/BlueBerryBank.sol#L142

    feeManager = config_.feeManager();

Above we see that feeManger is cached during initialization.

https://github.com/sherlock-audit/2023-05-blueberry/blob/main/blueberry-core/contracts/vault/HardVault.sol#L140-L143

    withdrawAmount = config.feeManager().doCutVaultWithdrawFee(
        address(uToken),
        shareAmount
    );

This is in direct conflict with other contracts the always use the freshest value. This is problematic for a few reasons. The desync will lead to inconsistent fees across the ecosystem either charging users too many fees or not enough.

Impact

After update users will experience inconsistent fees across the ecosystem

Code Snippet

https://github.com/sherlock-audit/2023-05-blueberry/blob/main/blueberry-core/contracts/BlueBerryBank.sol#L142

Tool used

Manual Review

Recommendation

BlueBerryBank should always use config.feeManger instead of caching it.

The original report as published on Sherlock, by 0x52. 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 bank contract caches the fee manager address at initialisation instead of reading it from config on each use, so it becomes stale when config is updated.

Impact

After the fee manager is updated, users could be charged inconsistent fees across the ecosystem, either too much or too little.

What the attacker needed

Fee manager updated in config after bank init

The fix

The bank contract should always read the fee manager from config instead of caching it.

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 smart contract stored a helper contract's address once when it was set up, but other contracts looked up the current address each time. When the helper was changed, the first contract kept using the old one, so fees were calculated differently in different places.

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 0x52

View all

211 more disclosed reports, best first.

More from Blueberry Update #3

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.