# Mushrooms Finance Logic Error Bugfix Review

Anyone-callable Strategy flashloan let attacker repay a Vault flashloan with Strategy's Compound wBTC, risking 19 wBTC ($635k).

- Payout: $60,000
- Severity: critical
- Program: Mushrooms Finance
- Credited: CKK Sec
- Disclosed: 2021-06-24
- Write-up quality: 7/10
- Original: https://immunefi.com/blog/bug-fix-reviews/mushrooms-finance-logic-error-bugfix-review/
- Library page: https://bugbountylibrary.com/r/blog%3Aimmunefi-com-blog-bug-fix-reviews-mushrooms-finance-logic-error-bugfix-review
- Tags: domain:web3 impact:funds-loss kind:bounty platform:blog platform:immunefi sev:critical tech:evm tech:solidity technique:chained vuln:business-logic vuln:flash-loan

**Target:** StrategyCmpdWbtcV1 Strategy contract and MMVault flashloan
**Root cause:** Strategy's mushroomsFlashloan() was callable by anyone and accepted attacker-controlled _amount and _fee, so the balanceOfWant() check could be bypassed and the Strategy would redeem wBTC from Compound to repay the Vault's flashloan.
**Steps:**
1. Flash loan wBTC from Uniswap.
2. Deposit wBTC into MMVault to get shares (Vault otherwise holds no wBTC).
3. Call MMVault flashloan to borrow wBTC into attack contract; keep it as profit.
4. Attack contract calls `mushroomsFlashloan(_amount=0, _fee=total)` on StrategyCmpdWbtcV1, repaying the Vault loan.
5. Strategy runs `redeemUnderlying(total)` on cwbtc and `IERC20(want).transfer(mwbtc, total)` to the Vault.
6. Withdraw shares from MMVault for extra wBTC.
7. Repay the Uniswap flash loan.
**How found:** Not described; report identifies the public mushroomsFlashloan() entrypoint and the attacker-controllable _amount/_fee parameters that bypass the balanceOfWant() check.
**Exploitation:** Attacker seeds the Vault with wBTC, borrows it via Vault flashloan, then uses the public Strategy flashloan with _amount=0 and _fee set to the borrowed amount so the Strategy redeems wBTC from Compound and transfers it to the Vault, settling the loan with Strategy funds. Attacker keeps the borrowed wBTC minus repayment of the external flash loan.
**Escalation:** Three chained flash loans (Uniswap -> MMVault -> Strategy) to route repayment through the victim's Compound position.
**Insight:** Look for callback-only functions (flashloan repay handlers) that lack access control and take caller-supplied amount/fee params; a zero _amount with inflated _fee can make the contract redeem its own collateral to settle someone else's loan.
