# Revest Finance: reentrancy in withdrawFNFT drains Rena

Reentrancy in Revest's withdrawFNFT via ERC1155 callback let attacker mint/deposit FNFTs and drain Rena tokens from the protocol.

- Payout: Real-world hack
- Severity: critical
- Program: Revest Finance
- Analysis by: DeFiHackLabs
- Disclosed: 2022-03-27
- Write-up quality: 6/10
- Original: https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2022-03/Revest_exp.sol
- Library page: http://bugbountylibrary.com/r/dhl%3A20220327-revest
- Tags: area:web3 domain:web3 impact:funds-loss kind:incident platform:defihacklabs sev:critical tech:evm tech:solidity technique:chained vuln:flash-loan vuln:reentrancy

**Target:** Revest FNFT mint/withdraw contract (ERC1155)
**Root cause:** withdrawFNFT triggers an ERC1155 receiver callback before state is finalized, allowing reentrant depositAdditionalToFNFT to manipulate FNFT accounting and over-withdraw underlying assets.
**Steps:**
1. Flash-swap 5e18 Rena from UniswapV2 pair `0xbC2C...70ca` via `pair.swap(5*1e18,0,address(this),new bytes(1))`.
2. In `uniswapV2Call`, approve Revest for max Rena.
3. Call `revest.mintAddressLock` with `isMulti=true`, quantity 2, then again with quantity 360000, obtaining fnftId and fnftId+1.
4. Call `revest.withdrawFNFT(fnftId+1, 360001)`; the ERC1155 callback `onERC1155Received` fires.
5. Inside callback, reenter `revest.depositAdditionalToFNFT(fnftId, 1e18, 1)` to inflate accounting.
6. Repay flash swap and transfer remaining Rena to tx.origin.
**Exploitation:** Attacker flash-borrows Rena, mints multi-quantity FNFTs, then withdraws triggering the ERC1155 receiver hook; reentering depositAdditionalToFNFT corrupts share accounting so the withdrawal pays out more Rena than deposited, repaying the flash loan and keeping the profit.
**Insight:** ERC1155-based FNFTs invoke onERC1155Received during withdraw; any state-changing deposit/mint reachable from that callback is a reentrancy surface — check ordering of balance updates vs. external calls in mint/withdraw paths.

