# wKeyDAO: unprotected buy() drained via flash loan

wKeyDAO's sell contract had an unprotected buy() function, letting an attacker flash-loan BUSD, buy wKeyDAO cheaply, and sell into PancakeSwap for profit.

- Payout: Real-world hack
- Severity: high
- Program: wKeyDAO
- Credited: DeFiHackLabs
- Disclosed: 2025-03-16
- Write-up quality: 6/10
- Original: https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2025-03/wKeyDAO_exp.sol
- Library page: https://bugbountylibrary.com/r/dhl%3A20250316-wkeydao
- Tags: domain:web3 impact:funds-loss kind:incident platform:defihacklabs sev:high tech:evm tech:solidity vuln:access-control vuln:business-logic vuln:flash-loan

**Target:** wKeyDAO sell contract (BSC)
**Root cause:** The wKeyDaoSell contract's buy() function lacked access control or pricing safeguards, allowing anyone to purchase wKeyDAO at a fixed/incorrect rate and arbitrage against the PancakeSwap market.
**Steps:**
1. Flash-loan 1,200 BUSD from DODO pool `0x107F3Be24e3761A91322AA4f5F54D9f18981530C`.
2. Approve BUSD to wKeyDaoSell `0xD511096a73292A7419a94354d4C1C73e8a3CD851`.
3. Approve wKeyDAO to PancakeSwap Router `0x10ED43C718714eb63d5aA57B78B54704E256024E`.
4. Loop 5 times: call `IwKeyDaoSell(wKeyDaoSell).buy()` to acquire wKeyDAO.
5. Swap acquired wKeyDAO for BUSD via `swapExactTokensForTokensSupportingFeeOnTransferTokens` on PancakeSwap.
6. Repay flash loan and keep profit.
**Exploitation:** Attacker flash-loaned BUSD, repeatedly called the unprotected buy() to obtain wKeyDAO at a favorable rate, then sold wKeyDAO on PancakeSwap for BUSD, netting ~767 US$ profit (per PoC comment; summary states 737,000 lost).
**Insight:** Look for public buy/sell functions in token sale contracts that lack access control or price checks; they can be arbitraged against DEX pools using flash loans.
