Full Report
bDollar is a algorithmic stablecoin on the Binance Smartchain. It is pegged to multiply assets. The contract attempts to do some asset rebalancing depending on what assets are in or out of the contract. When using CAKE tokens for conversion, it will try to judge the amount of WBNB exchanged. From this, it will exchange half of the WBNB for BDO tokens and use to this add liquidity to the pool. If the value of the BDO token is raised during that process, the project will use more WBNB to add liquidity to the pool. To raise the price of BDO, they exchanged a large amount of BDO tokens in several other pools to create a price raise with flash loaned funds. The key problem is that the contract will automatically replenish the liquidity for the pool without considering if the token price is out of balance. So, the project will supplement the liquidity at a high price to over the order at a higher price. The exploit happens when performing a swap call.
Analysis Summary
# Incident Report: bDollar Price Manipulation & Liquidity Exploitation
## Executive Summary
On April 30, 2022, the bDollar protocol on the Binance Smart Chain (BSC) was exploited via a price manipulation attack targeting the `CommunityFund` contract. The attacker utilized flash loans to artificially inflate the price of BDO tokens, forcing the protocol to add liquidity at an unfavorable rate, resulting in a loss of approximately $730,000 (2,381 WBNB). The incident was further complicated by "front-running" bots that successfully executed the attack ahead of the original exploiter by using high gas fees.
## Incident Details
- **Discovery Date:** April 30, 2022
- **Incident Date:** April 30, 2022
- **Affected Organization:** bDollar
- **Sector:** Decentralized Finance (DeFi)
- **Geography:** Global / Distributed (BSC Chain)
## Timeline of Events
### Initial Access
- **Date/Time:** April 30, 2022 (Beijing Time)
- **Vector:** Exploitation of the `claimAndReinvestFromPancakePool` function logic.
- **Details:** The attacker initiated the sequence by securing flash loans of 670 WBNB and 30,516 CAKE tokens to provide the necessary capital for market manipulation.
### Lateral Movement
- **Not Applicable:** As a DeFi smart contract exploit, the "movement" involved interacting with multiple liquidity pools (WBNB/BDO, CAKE/BDO, BUSD/BDO) to manipulate the internal price oracle/valuation of the BDO token.
### Data Exfiltration/Impact
- **Financial Loss:** A total of 2,381 WBNB was drained from the protocol.
- **Asset Conversion:** The attacker swapped manipulated BDO tokens for WBNB to repay flash loans and net the profit.
### Detection & Response
- **Detection:** Knownsec Blockchain Lab detected the anomaly on the day of the attack.
- **Analysis:** Analysts identified that a front-running bot (using 2000 Gwei gas) beat the original attacker to the transaction.
- **Response Actions:** Post-incident analysis was conducted to identify the flawed liquidity replenishment logic.
## Attack Methodology
- **Initial Access:** Smart contract vulnerability exploitation.
- **Persistence:** Not applicable; atomic transaction (flash loan).
- **Privilege Escalation:** Not applicable.
- **Defense Evasion:** Use of front-running bots and high gas fees to ensure transaction priority in the mempool.
- **Credential Access:** None required.
- **Discovery:** Identification of the `claimAndReinvestFromPancakePool` method which lacked slippage or price balance checks.
- **Lateral Movement:** Inter-pool swapping to skew BDO price ratios across the ecosystem.
- **Collection:** Accumulation of BDO tokens at a low cost before manipulating the price upward.
- **Exfiltration:** Conversion of BDO to 3,020 WBNB through decentralized exchanges.
- **Impact:** Forced the protocol to "take over the order" by adding liquidity at an artificially high price, effectively buying the attacker's inflated BDO via the contract's automated logic.
## Impact Assessment
- **Financial:** Estimated loss of $730,000 USD.
- **Data Breach:** None (non-custodial protocol).
- **Operational:** Disruption of the bDollar algorithmic peg and liquidity provision mechanisms.
- **Reputational:** Significant loss of trust in the bDollar project’s security and smart contract logic.
## Indicators of Compromise
- **Attacker Address:** `0x9dadbd8c507c6acbf1c555ff270d8d6ea855178e`
- **Attack Contract:** `0x6877f0d7815b0389396454c58b2118acd0abb79a`
- **Transaction Hash:** `0x9b16b1b3bf587db1257c06bebd810b4ae364aab42510d0d2eb560c2565bbe7b4`
- **Behavioral Indicators:** Abnormal gas prices (~2000 Gwei) and high-volume flash loan activity followed by immediate swaps.
## Response Actions
- **Containment:** The attack was an atomic transaction; containment focused on identifying the vulnerability to prevent repeat occurrences.
- **Eradication:** Identification of the flawed `CommunityFund` contract: `0xEca7fC4c554086198dEEbCaff6C90D368dC327e0`.
- **Recovery:** Analysis by security firms to inform the community and protocol developers of the breach.
## Lessons Learned
- **Oracle Reliance:** Contracts that automate liquidity addition must use secure, TWAP-based (Time-Weighted Average Price) or multi-source oracles rather than internal pool balances.
- **Slippage Checks:** Automated reinvestment functions must include checks to ensure liquidity is not being added when prices are significantly out of balance.
- **MEV Awareness:** The prevalence of front-running bots means that even if a vulnerability is discovered by a "white hat" or a specific attacker, a third-party bot may ultimately capture the funds.
## Recommendations
- **Implement Price Guards:** Introduce slippage tolerance limits on all functions that automatically swap or add liquidity.
- **External Audits:** Conduct comprehensive security audits specifically focusing on flash loan resistance and price manipulation scenarios.
- **Emergency Pause:** Implement a "Circuit Breaker" or emergency pause functionality for the `CommunityFund` contract to stop operations during high-volatility manipulation events.