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.
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
feeManager = config_.feeManager();
Above we see that feeManger is cached during initialization.
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
Tool used
Manual Review
Recommendation
BlueBerryBank should always use config.feeManger instead of caching it.
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.