# Gangsterfinance: incorrect dividends in TokenVault exploited

Gangsterfinance TokenVault dividend calculation flaw allowed attacker to donate, deposit, resolve, and harvest to steal 16.5k USD via flash loan.

- Payout: Real-world hack
- Severity: high
- Program: Gangsterfinance
- Credited: DeFiHackLabs
- Disclosed: 2025-06-20
- Write-up quality: 6/10
- Original: https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2025-06/Gangsterfinance_exp.sol
- Library page: https://bugbountylibrary.com/r/dhl%3A20250620-gangsterfinance
- Tags: domain:web3 impact:funds-loss kind:incident platform:defihacklabs sev:high technique:chained vuln:business-logic vuln:flash-loan vuln:reward-distribution

**Target:** TokenVault contract on BSC
**Root cause:** Incorrect dividend calculation in TokenVault allows manipulation of share price via donate and deposit, enabling profit from resolve and harvest.
**Steps:**
1. Flash loan 1.02 BTCB from PancakeSwap CAKE_LP via swap.
2. Approve TokenVault to spend borrowed BTCB.
3. Call donate(1e18) to inflate dividend pool.
4. Call depositTo(address(this), 0.01572e18) to receive shares.
5. Call resolve(myTokens()) to convert shares to BTCB.
6. Call harvest() to claim dividends.
7. Repay flash loan with 1.022652e18 BTCB to CAKE_LP.
**Exploitation:** Attacker used flash loan to borrow BTCB, manipulated TokenVault's dividend mechanism by donating and depositing small amount, then resolved shares and harvested dividends for profit, repaid loan, netting ~16.5k USD.
**Insight:** In dividend-bearing vaults, check if donate/deposit/resolve/harvest sequence can be used to inflate share value or claim disproportionate dividends, especially when donation affects share price.
