📈 Get daily crypto insights that make you smarter about your money

Understanding Flash Loan Attack Vectors: An Advanced Technical Walkthrough of the Citadel Finance Exploit

On January 27, 2024, Citadel Finance on Arbitrum lost 43 ETH (approximately $93,000) to a flash loan attack exploiting price manipulation in its redemption contract. For developers and advanced users seeking to understand — and defend against — this class of vulnerability, this technical walkthrough dissects the exact attack vector and examines the code-level failures that enabled the exploit.

The Objective

This guide aims to provide a comprehensive understanding of how flash loan price manipulation attacks work in practice, using the Citadel Finance exploit as a real-world case study. By the end, you will be able to identify vulnerable code patterns in DeFi protocols, understand the economics of flash loan attacks, and implement defensive measures in your own smart contract development.

Prerequisites

This walkthrough assumes familiarity with Solidity smart contract development, an understanding of Automated Market Maker (AMM) mechanics, and basic knowledge of how flash loans operate on Ethereum and EVM-compatible chains. You should be comfortable reading Solidity code and understanding function calls, token approvals, and DEX routing mechanisms. Familiarity with Arbitrum and the Camelot DEX will be helpful but is not required.

Step-by-Step Walkthrough

Step 1: Understanding the vulnerable contract. The CITRedeem contract on Arbitrum handles token redemptions for Citadel Finance. The critical vulnerability lies in the variable-rate redemption path. When a user calls the redeem function with rate parameter set to 0 (variable rate), the contract uses the Camelot Router’s getAmountsOut function to determine the exchange rate. The routing path goes through three hops: CIT to WETH to USDC. This means the redemption value depends entirely on the current spot price in the Camelot liquidity pools — a price that can be manipulated.

Step 2: The flash loan acquisition. The attacker borrowed approximately 4,500 WETH through a flash loan from a lending protocol. Flash loans allow borrowing any amount of capital without collateral, provided the loan is repaid within the same transaction. This single-transaction constraint is what makes flash loans powerful for arbitrage and, unfortunately, for exploits. The attacker now had a massive capital advantage to distort market prices.

Step 3: Pool price manipulation. The attacker deposited the 4,500 WETH into the Camelot WETH/USDC liquidity pool. In an AMM, the price is determined by the ratio of tokens in the pool. By adding a massive amount of WETH relative to USDC, the attacker skewed the pool’s internal price ratio, making WETH appear artificially cheap relative to USDC. This is the core mechanism of any AMM-based price manipulation attack.

Step 4: Exploiting the distorted price. With the pool price manipulated, the attacker called redeem on the CITRedeem contract. The contract queried the now-distorted Camelot Router for the exchange rate, which returned an inflated redemption value. The attacker burned only 30.51 CIT tokens but received 21.326 WETH from the treasury — a vastly disproportionate exchange enabled by the manipulated oracle.

Step 5: Loan repayment and profit extraction. The attacker withdrew their 4,500 WETH from the Camelot pool, restoring the price to its natural level. They then repaid the flash loan from the same transaction. The net profit was the 21.326 WETH extracted from Citadel’s treasury, worth approximately $48,000 at the ETH price of roughly $2,267 at the time of the attack.

Troubleshooting

Identifying vulnerable patterns in your own code: Any contract that uses spot prices from AMM pools for financial calculations is vulnerable. Search your codebase for calls to getAmountsOut, getAmountIn, or direct reserve-based price calculations. Replace these with time-weighted average prices (TWAP) from Uniswap V2/V3 or use Chainlink price feeds.

Testing for flash loan vulnerability: Use Foundry or Hardhat to write tests that simulate flash loan attacks against your protocol. Create a test that borrows a large amount of capital within a single transaction, manipulates the pool price, and then interacts with your contract. If the attacker can extract more value than they should, your contract is vulnerable. Automated tools like Slither can also detect some price manipulation patterns.

Implementing circuit breakers: Add checks that compare the current spot price against a time-weighted average. If the deviation exceeds a reasonable threshold — typically 5-10% — the transaction should revert. This simple measure would have prevented the Citadel Finance exploit entirely, as the price manipulation from a 4,500 WETH deposit would have exceeded any reasonable deviation threshold.

Mastering the Skill

Flash loan attack vectors represent one of the most active areas of DeFi security research. To deepen your expertise, study historical exploits on Rekt News, which maintains a comprehensive database of DeFi hacks sorted by severity. Analyze the attack transactions on block explorers — the Citadel Finance attacker transaction on Arbiscan (0xf52a681…) provides a complete blueprint of the attack for educational purposes. Practice writing defensive Solidity code that implements TWAP oracles, rate limits, and emergency pause mechanisms. The most effective security measure is always a thorough audit by experienced smart contract security firms before deploying any DeFi protocol to mainnet.

Disclaimer: This article is for educational purposes only. The technical analysis is provided to help developers build more secure smart contracts. Always conduct professional security audits before deploying financial smart contracts.

🌱 FOR BUSINESSES BitcoinsNews.com
Reach 100K+ Crypto Readers
Sponsored content, press releases, banner ads, and newsletter placements. Put your brand in front of Bitcoin's most engaged audience.

11 thoughts on “Understanding Flash Loan Attack Vectors: An Advanced Technical Walkthrough of the Citadel Finance Exploit”

  1. 43 ETH for a flash loan attack feels almost small time these days, but the redemption contract vector is what makes this interesting. most devs still dont properly validate oracle inputs during the callback

    1. price-dependent redemption logic without TWAP protection is basically leaving your front door open. this attack pattern has been documented since 2020

    2. the redemption contract specifically lacked any freshness check on the price. not even a stale price threshold. literally the minimum you could do and they skipped it

      1. Marco L. not even a stale threshold check. the dev literally just called the spot price once and used it. first year smart contract course material right there

  2. The fact that Citadel was on Arbitrum makes the gas cost of the attack basically negligible. attacker probably spent more time writing the exploit than the actual execution cost

    1. arbitrum gas being basically free means flash loan attacks cost pennies to execute. the ROI on a 43 eth exploit is insane

      1. Devon C. the ROI math on L2 flash loans is insane. spend 2 cents on gas to extract 93k. mainnet would have eaten margins on an attack this size

    2. ^ exactly. and on L2s the flash loan fees are trivial compared to mainnet, which lowers the barrier for attackers significantly. any protocol with price-dependent logic needs time-weighted oracles at minimum

    3. the writeup says attacker spent more time coding than on gas fees lol. $93k exploited for probably $2 in Arbitrum gas. asymmetric warfare

      1. $93k extracted for basically free gas on arbitrum. the ROI on flash loan attacks on L2s is absurd which is why auditors need to treat price oracle validation as critical path

Leave a Comment

Your email address will not be published. Required fields are marked *

BTC$62,796.00-2.0%ETH$1,669.50-3.5%SOL$69.84-2.7%BNB$578.40-2.0%XRP$1.11-1.6%ADA$0.1525-3.9%DOGE$0.0793-3.0%DOT$0.9123-2.1%AVAX$6.43+2.5%LINK$7.63-3.0%UNI$2.92-2.2%ATOM$1.72-3.9%LTC$42.03-5.5%ARB$0.0785-5.0%NEAR$1.98-2.9%FIL$0.7900-0.3%SUI$0.7026-2.0%BTC$62,796.00-2.0%ETH$1,669.50-3.5%SOL$69.84-2.7%BNB$578.40-2.0%XRP$1.11-1.6%ADA$0.1525-3.9%DOGE$0.0793-3.0%DOT$0.9123-2.1%AVAX$6.43+2.5%LINK$7.63-3.0%UNI$2.92-2.2%ATOM$1.72-3.9%LTC$42.03-5.5%ARB$0.0785-5.0%NEAR$1.98-2.9%FIL$0.7900-0.3%SUI$0.7026-2.0%
Scroll to Top