# AvaxBIFKNPair: flash-swap accounting inflates LP mint

BIFKN314 flashSwap checked repayment only after the callback, letting an attacker add dust liquidity against distorted reserves, mint oversized LP shares, and drain ~2.4K USD in AVAX.

- Payout: Real-world hack
- Severity: high
- Program: AvaxBIFKNPair
- Credited: DeFiHackLabs
- Disclosed: 2025-07-28
- Write-up quality: 7/10
- Original: https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2025-07/AvaxBIFKNPair_exp.sol
- Library page: https://bugbountylibrary.com/r/dhl%3A20250728-avaxbifknpair
- Tags: domain:web3 impact:funds-loss kind:incident platform:defihacklabs sev:high tech:evm tech:solidity technique:chained vuln:accounting-error vuln:business-logic vuln:flash-loan vuln:oracle-manipulation

**Target:** BIFKN314 AMM pair contract (flashSwap/addLiquidity/removeLiquidity)
**Root cause:** flashSwap verifies repayment only after invoking BIFKN314CALL, so during the callback the pool reserves are distorted by the flash-swap outputs; addLiquidity then mints LP shares based on those skewed balances rather than the actual dust contribution.
**Steps:**
1. Fork Avalanche at block 66181042; confirm attacker EOA is allowlisted (slot 6) for the pair token transfer gate.
2. Borrow 1000 WAVAX from Aave v3 via flashLoanSimple.
3. In executeOperation, call RadioShack pair.swap(0, PAIR_TOKEN_BORROW, attacker, 'flash').
4. In uniswapV2Call, WAVAX.withdraw(1000 ether) to native AVAX.
5. Call VICTIM.flashSwap(attacker, FLASH_NATIVE_OUT, FLASH_TOKEN_OUT, '').
6. In BIFKN314CALL, call VICTIM.addLiquidity{value: LIQUIDITY_NATIVE}(LIQUIDITY_TOKEN, attacker, deadline) with dust amounts while reserves are distorted, minting oversized LP shares.
7. Repay victim flash swap with FLASH_NATIVE_REPAY and FLASH_TOKEN_REPAY.
8. Approve and removeLiquidity(lpBalance) to burn inflated LP for AVAX + tokens.
9. Mint PAIR_TOKEN_MINT of pair token, transfer PAIR_TOKEN_REPAY to RadioShack pair to settle its flash swap.
10. Wrap AVAX, repay Aave (amount+premium), forward remaining AVAX profit (>90 ether) to attacker.
**How found:** Recognized that flashSwap's repayment check occurs after the callback, so pool balances are temporarily skewed; hypothesized addLiquidity during the callback would mint LP proportional to distorted reserves rather than actual deposit.
**Exploitation:** Attacker flash-borrows WAVAX from Aave and pair tokens from a RadioShack pair, unwraps to AVAX, then uses the victim's flashSwap to extract AVAX and tokens. Inside the BIFKN314CALL callback, before repayment is checked, they add dust liquidity against distorted reserves to mint inflated LP shares, then burn them via removeLiquidity for profit. Pair-token repayment is covered by minting the fee amount; AVAX profit is retained after repaying Aave.
**Escalation:** Nested flash loans (Aave + RadioShack pair + victim flashSwap) to amplify capital and distort reserves before the accounting check.
**Insight:** In AMM forks, check whether flash-swap/flash-loan callbacks run before reserve/repayment validation; any liquidity-mint or price function callable inside that window can be gamed by depositing dust against skewed reserves.
