# BaoCommunity bdbSTBL: donation inflation and rounding drain

BaoCommunity bdbSTBL lending market drained via donation-inflated exchange rate plus rounding error, netting attacker ~$46k.

- Payout: Real-world hack
- Severity: high
- Program: BaoCommunity
- Analysis by: DeFiHackLabs
- Disclosed: 2023-07-04
- Write-up quality: 7/10
- Original: https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2023-07/Bao_exp.sol
- Library page: https://bugbountylibrary.com/r/dhl%3A20230704-bao
- Tags: area:web3 domain:web3 impact:funds-loss kind:incident platform:defihacklabs sev:high tech:evm tech:solidity vuln:accounting-error vuln:flash-loan vuln:precision-loss vuln:share-inflation

**Target:** bdbSTBL Compound-style lending market on bSTBL
**Root cause:** bdbSTBL exchange rate is derived from underlying token balance, so directly transferring bSTBL to the market inflates the rate; combined with rounding on mint/redeem of tiny share amounts, the attacker redeems far more underlying than deposited.
**Steps:**
1. Flash loan 17.55M USDC and 17.51M DAI from Aave V2.
2. Deposit into Aave, then `bSTBL.joinPool(34_819_000 * 1e18 + 1)` to mint bSTBL underlying.
3. `bdbSTBL.mint(1, true)` to mint a tiny share position, then `bdbSTBL.redeem(3)` leaving 2 shares.
4. `bSTBL.transfer(address(bdbSTBL), 34_819_000 * 1e18)` to donate and inflate the exchange rate.
5. `bdbaoETH.borrow(41.3 ether)` against the inflated collateral.
6. `bdbSTBL.redeemUnderlying(34_819_000 * 1e18)` to withdraw nearly all underlying.
7. `bSTBL.exitPool(34_819_000 * 1e18)` to redeem USDC/DAI, repay Aave, swap baoETH to USDC/DAI via Balancer and Uniswap V3.
**How found:** Recognized the same donation/inflation pattern as the Hundred Finance April 2023 exploit (referenced in the PoC) applied to a Compound-fork market whose exchange rate reads raw token balance.
**Exploitation:** Attacker flash-borrowed ~$35M, minted bSTBL, opened a 2-share bdbSTBL position, donated the full bSTBL balance to the market to spike the exchange rate, borrowed 41.3 baoETH against the inflated collateral, then redeemed underlying at the inflated rate and exited the pool, repaying the flash loan and keeping the baoETH proceeds swapped to stables.
**Escalation:** Donation-inflated exchange rate amplified by rounding on a 2-share position, letting a tiny share redeem the entire donated underlying plus borrowed baoETH.
**Insight:** On Compound-fork markets, check whether exchangeRate is computed from token.balanceOf(this); if so, a direct transfer inflates collateral value. Pair with tiny mint/redeem to exploit rounding on share math.

