# GoodDollar: unvalidated collectInterest reentrancy drains ~$2M

GoodFundManager.collectInterest lacked validation of staking contracts and reentered via collectUBIInterest callback, letting attacker mint/sell GoodDollar against cDAI to drain ~$2M.

- Payout: Real-world hack
- Severity: critical
- Program: GoodDollar
- Analysis by: DeFiHackLabs
- Disclosed: 2023-12-16
- Write-up quality: 7/10
- Original: https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2023-12/GoodDollar_exp.sol
- Library page: https://bugbountylibrary.com/r/dhl%3A20231216-gooddollar
- Tags: area:web3 domain:web3 impact:funds-loss kind:incident platform:defihacklabs sev:critical tech:evm tech:solidity technique:chained vuln:business-logic vuln:flash-loan vuln:reentrancy

**Target:** GoodFundManager.collectInterest / GDX buy-sell bonding curve
**Root cause:** collectInterest accepted an arbitrary attacker-controlled staking contract and invoked its collectUBIInterest callback without validation, allowing reentrancy into GDX.buy during interest collection.
**Steps:**
1. Flash loan WETH from Balancer
2. Withdraw WETH, mint cETH, enterMarkets, borrow all cDAI cash
3. Mint cDAI and approve GDX; GDX.buy GoodDollar with 95% of cDAI
4. Deploy MaliciousStakingContract, transfer remaining cDAI to it
5. Call deposit() twice: collectInterest([malicious], true) triggers collectUBIInterest callback which reenters GDX.buy with cDAI balance
6. Sell accumulated GoodDollar via GDX.sell(5_090_998_266_365,...)
7. Redeem cDAI, repay borrow, redeem cETH, wrap ETH, repay Balancer
**How found:** Likely source review of GoodFundManager.collectInterest noticing it trusts caller-supplied staking contract addresses and calls back into them, enabling reentrancy into the GDX bonding curve.
**Exploitation:** Attacker flash-borrowed WETH, leveraged Compound (cETH collateral, cDAI borrow) to obtain DAI, bought GoodDollar via GDX, then used a malicious staking contract passed to collectInterest to reenter GDX.buy inside the collectUBIInterest callback, inflating GoodDollar holdings before selling back into GDX for profit.
**Escalation:** Leverage via Compound cETH/cDAI plus flash loan amplified capital; repeated deposit() calls multiplied reentrancy buys.
**Insight:** Interest-harvesting functions that iterate caller-supplied contract lists and invoke callbacks are prime reentrancy surfaces; check whether the callback can reenter the same bonding-curve buy/sell used for accounting.
