# RFB: predictable randomness exploited via flash loan

RFB token on BSC used predictable randomness for its fee/reward mechanism, letting an attacker brute-force swap amounts to profit 12 BNB.

- Payout: Real-world hack
- Severity: high
- Program: - RFB
- Analysis by: DeFiHackLabs
- Disclosed: 2022-12-05
- Write-up quality: 6/10
- Original: https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2022-12/RFB_exp.sol
- Library page: http://bugbountylibrary.com/r/dhl%3A20221205-rfb
- Tags: area:web3 domain:web3 impact:funds-loss kind:incident platform:defihacklabs sev:high tech:evm vuln:business-logic vuln:oracle-manipulation

**Target:** RFB token contract on BSC
**Root cause:** The token's transfer logic relied on a predictable random number (likely block.timestamp or similar) to determine fees or rewards, allowing an attacker to brute-force transaction amounts until a profitable outcome occurred.
**Steps:**
1. Flash loan 20 WBNB from DODO.
2. Withdraw WBNB to BNB.
3. Loop i from 0 to 49: call `check(20e18 - i)` which attempts a swap BNB->RFB->BNB and requires profit.
4. If profitable, keep the profit; otherwise revert and try next amount.
5. Repay flash loan and keep remaining BNB.
**How found:** The attacker likely noticed that the RFB token's transfer logic used a predictable random number (e.g., block.timestamp) to determine fees or rewards, and realized they could brute-force transaction amounts to find a profitable outcome.
**Exploitation:** Attacker used a DODO flash loan of 20 WBNB, converted to BNB, then iterated over swap amounts (20e18 - i) to find one that yielded a profit due to the token's predictable randomness affecting fees or rewards. The profitable swap was executed, and the loan repaid, netting 12 BNB.
**Insight:** When a token's fee or reward mechanism depends on a predictable on-chain value (like block.timestamp), an attacker can brute-force transaction parameters (e.g., swap amount) to trigger favorable outcomes, especially when combined with flash loans for capital.

