# Interest component of underlying amount is not withdrawable using the `withdrawLend` function. Such amount is permanently locked in the BlueBerryBank contract

BlueBerryBank.withdrawLend caps payout to original deposit while burning full vault shares, permanently locking accrued Compound interest in the contract.

- Payout: Contest reward
- Severity: high
- Program: Blueberry
- Credited: berndartmueller
- Disclosed: 2023-02-01
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2023-02-blueberry-judging/issues/109
- Library page: https://bugbountylibrary.com/r/sherlock%3A2023-02-blueberry%3AH-8
- Tags: domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:evm tech:solidity technique:source-review vuln:accounting-error

**Target:** BlueBerryBank.withdrawLend / SoftVault (Compound cTokens)
**Root cause:** withdrawLend caps wAmount to pos.underlyingAmount but subtracts the full shareAmount from pos.underlyingVaultShare, so interest-bearing shares are burned while only principal is returned.
**Steps:**
1. Alice calls `lend` with 1000 USDC into SoftVault; bank receives 1000 soft vault shares backed by 1000 cUSDC.
2. After 60 days, Alice calls `withdrawLend(token, 1000)` requesting full shareAmount.
3. SoftVault burns 1000 shares, redeems 1050 USDC from Compound, sends to BlueBerryBank.
4. BlueBerryBank caps `wAmount` to `pos.underlyingAmount` (1000), deducts full `shareAmount` from `pos.underlyingVaultShare`, transfers only 995 USDC after fee.
5. 50 USDC interest remains trapped; Alice has no shares left to claim it.
**How found:** Code review of withdrawLend noticed the mismatch between capping wAmount to pos.underlyingAmount and decrementing pos.underlyingVaultShare by the full shareAmount, implying interest-bearing shares are burned without corresponding payout.
**Exploitation:** Any lender withdrawing full position loses accrued interest to the contract; no attacker needed, loss is to the user and funds are permanently stuck.
**Insight:** In lending wrappers, check that the share amount burned and the underlying amount paid out are decremented consistently; capping one but not the other strands the difference.
