# Defrost LSWUSDC: flash-loan reentrancy drains USDC vault

Defrost LSWUSDC flash-loan reentrancy let attacker re-enter redeem during deposit callback, draining ~$170k USDC on Avalanche.

- Payout: Real-world hack
- Severity: high
- Program: - Defrost
- Analysis by: DeFiHackLabs
- Disclosed: 2022-12-23
- Write-up quality: 6/10
- Original: https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2022-12/Defrost_exp.sol
- Library page: http://bugbountylibrary.com/r/dhl%3A20221223-defrost
- Tags: area:web3 domain:web3 impact:funds-loss kind:incident platform:defihacklabs sev:high tech:evm tech:solidity vuln:flash-loan vuln:reentrancy vuln:share-inflation

**Target:** LSWUSDC ERC3156 flash-loan vault on Avalanche
**Root cause:** The vault's flashLoan callback path allowed reentrant interaction with deposit/redeem share accounting, so shares could be redeemed before the deposit state settled, inflating redeemable value.
**Steps:**
1. Fork Avalanche at block 24003940.
2. Query `LSW.maxFlashLoan(USDC)` and `LSW.flashFee(USDC, amount)`.
3. Borrow via Joe pair swap callback `joeCall`, which calls `LSW.flashLoan(address(this), USDC, flashLoanAmount, ...)`.
4. In `onFlashLoan`, approve LSW and call `LSW.deposit(flashLoanAmount, address(this))` to mint shares.
5. Reenter `LSW.redeem(depositAmount, address(this), address(this))` in `joeCall` after flashLoan returns, redeeming shares for more USDC than deposited.
6. Repay Joe pair `(flashLoanAmount + flashLoanFee) * 1000 / 997 + 1000` and keep profit.
**Exploitation:** Attacker flash-borrows max USDC from the LSW vault via a Joe pair swap callback, deposits into LSW to mint shares, then reenters redeem to extract more USDC than deposited, repays the Joe pair loan plus fee, and keeps the difference (~$170k).
**Insight:** ERC3156 flash-loan receivers that also expose deposit/redeem share accounting are prime reentrancy targets: check whether the callback can reenter mint/redeem before state settles, and whether share price can be manipulated within the same tx.

