Flawed Logic in `ShareManager` Inverts Transfer Whitelist Behavior
The updateChecks function in ShareManager.sol inverts the transfer whitelist logic, causing transfers from whitelisted accounts to be blocked instead of allowed. An attacker could not exploit this directly, but it breaks the intended security feature and disrupts vault operations.
Source: https://github.com/sherlock-audit/2025-07-mellow-flexible-vaults-judging/issues/26
Found by
0rpse, 0x23r0, 0xDLG, 0xShoonya, 0xc0ffEE, 0xloophole, 0xpetern, 7, ARMoh, Arav, Brene, Cybrid, DeveloperX, Etherking, Greed, GypsyKing18, HeckerTrieuTien, KupiaSec, Mishkat6451, PratRed, SilentVoice-dev, Sparrow_Jac, TopStar, ZanyBonzy, algiz, axelot, bXiv, bam0x7, blockace, boredpukar, bughuntoor, coin2own, dan__vinci, davies0212, dimulski, edger, elyas, holtzzx, illoy_sci, jah, joicygiore, jolyon, ke1caM, klaus, lazyrams352, lodelux, maigadoh, natachi, odessos42, pollersan, rbd3, reedai, silver_eth, slavina, snapishere, t.aksoy, taticuvostru, teoslaf1, v1c7, who_is_rp, wickie, x0rc1ph3r, zxriptor
Summary
The updateChecks function in ShareManager.sol:L139 contains flawed logic that inverts the intended behavior of the transfer whitelist feature. Instead of allowing transfers from whitelisted accounts, the code incorrectly blocks them, rendering the security feature unusable and creating behavior that is opposite to the documentation.
Vulnerability Detail
The updateChecks function is responsible for enforcing security policies before any share modification. When the hasTransferWhitelist flag is enabled, it is supposed to check if a transfer is permitted. The logic for this check is as follows:
Here, info represents the sender's account data. The code reverts if the sender's canTransfer flag is true. This is a direct contradiction of the feature's documented intent in the IShareManager.sol interface:
/// @notice Whether the account is allowed to transfer (send or receive) shares when the `hasTransferWhitelist` flag is active.
bool canTransfer;
The documentation clearly states that canTransfer: true should allow an account to send or receive shares. The current implementation enforces the opposite, blocking whitelisted senders. Furthermore, the project's test suite (ShareManager.t.sol) confirms this flawed logic by explicitly expecting a revert when a whitelisted address attempts to send shares.
#PoC
function testUpdateChecks_TransferWhitelist_Inclusive() external {
// --- Setup ---
Deployment memory deployment = createVault(vaultAdmin, vaultProxyAdmin, assetsDefault);
ShareManager manager = deployment.shareManager;
address from = vm.createWallet("from").addr;
address to = vm.createWallet("to").addr;
vm.startPrank(deployment.vaultAdmin);
// Enable the transfer whitelist
manager.setFlags(
IShareManager.Flags({
hasMintPause: false,
hasBurnPause: false,
hasWhitelist: false,
hasTransferPause: false,
hasTransferWhitelist: true, // <-- Feature is ON
globalLockup: 0, // No lockup
targetedLockup: 0 // No lockup
})
);
// Case 1: Neither is whitelisted. SHOULD REVERT. This is correct behavior.
manager.setAccountInfo(from, IShareManager.AccountInfo({canDeposit: true, canTransfer: false, isBlacklisted: false, lockedUntil: 0}));
manager.setAccountInfo(to, IShareManager.AccountInfo({canDeposit: true, canTransfer: false, isBlacklisted: false, lockedUntil: 0}));
vm.expectRevert(abi.encodeWithSelector(IShareManager.TransferNotAllowed.selector, from, to));
manager.updateChecks(from, to);
// Case 2: Sender is whitelisted, Receiver is not. SHOULD PASS, BUT REVERTS. This proves the bug.
manager.setAccountInfo(from, IShareManager.AccountInfo({canDeposit: true, canTransfer: true, isBlacklisted: false, lockedUntil: 0}));
manager.setAccountInfo(to, IShareManager.AccountInfo({canDeposit: true, canTransfer: false, isBlacklisted: false, lockedUntil: 0}));
vm.expectRevert(abi.encodeWithSelector(IShareManager.TransferNotAllowed.selector, from, to));
manager.updateChecks(from, to);
// Case 3: Sender is not, Receiver is whitelisted. SHOULD PASS. This case correctly passes.
manager.setAccountInfo(from, IShareManager.AccountInfo({canDeposit: true, canTransfer: false, isBlacklisted: false, lockedUntil: 0}));
manager.setAccountInfo(to, IShareManager.AccountInfo({canDeposit: true, canTransfer: true, isBlacklisted: false, lockedUntil: 0}));
manager.updateChecks(from, to); // No expectRevert, this succeeds as intended.
// Case 4: Both are whitelisted. SHOULD PASS, BUT REVERTS. This also proves the bug.
manager.setAccountInfo(from, IShareManager.AccountInfo({canDeposit: true, canTransfer: true, isBlacklisted: false, lockedUntil: 0}));
manager.setAccountInfo(to, IShareManager.AccountInfo({canDeposit: true, canTransfer: true, isBlacklisted: false, lockedUntil: 0}));
vm.expectRevert(abi.encodeWithSelector(IShareManager.TransferNotAllowed.selector, from, to));
manager.updateChecks(from, to);
vm.stopPrank();
}
Impact
The primary impact is the complete failure of the transfer whitelist feature. A vault operator who enables this feature and whitelists accounts by setting canTransfer to true will find that these accounts are unexpectedly blocked from making transfers. This subverts the intended security model and can disrupt the vault's operations. Because the code behaves in the exact opposite manner of its documentation, this is an issue that can lead to confusion and operational failure.
Recommendation
To fix the inverted logic, the updateChecks function should only revert if both the sender and receiver are not whitelisted. This aligns the implementation with the documented behavior.
The flawed line:
function updateChecks(/*params*/) public view {
// code
.
.
- if (info.canTransfer || !$.accounts[to].canTransfer) {
+ if (!info.canTransfer && !$.accounts[to].canTransfer) {
// rest of code
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/mellow-finance/flexible-vaults/pull/3
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 condition in updateChecks uses OR instead of AND, so it reverts when the sender is whitelisted or the receiver is not, instead of only when both are not whitelisted.
Impact
The transfer whitelist feature is completely broken: whitelisted accounts are blocked from transferring, which can disrupt vault operations and subvert the intended security model.
What the attacker needed
Vault operator enables transfer whitelist; accounts are whitelisted
The fix
The condition should be changed to revert only when both the sender and receiver are not whitelisted, and the protocol team fixed this issue.
How it was found
- Enable the transfer whitelist by setting hasTransferWhitelist to true.
- Set the sender's canTransfer to true and the receiver's canTransfer to false.
- Call updateChecks and observe that it reverts, even though the sender is whitelisted.
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 has a feature to allow only certain accounts to transfer shares. The code that checks this has a mistake: it blocks the accounts that should be allowed. This means the feature does the opposite of what it is supposed to do.
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.