A flash loan is a DeFi mechanism that allows a user to temporarily borrow a large amount of assets without traditional collateral, provided that the entire loan is repaid within the same blockchain transaction. If the repayment condition is not satisfied, the transaction can revert and the intermediate state changes are not retained.

The mechanism depends on the programmability and atomic execution of smart contracts. Within one transaction, a user can borrow assets, execute several operations across other protocols, and return the borrowed amount plus the required fee.

One common use case is arbitrage. A user can temporarily borrow an asset, trade it where it is relatively cheap, sell it where it is relatively expensive, and repay the loan. If the complete sequence does not produce enough value to cover the loan and fees, the transaction should fail.

Flash loans can also be used for refinancing, collateral restructuring, complex swaps, and other atomic operations. The borrower does not need to own capital equal to the loan amount because the funds are only temporarily available during transaction execution.

Flash loans can become relevant to protocol security because they allow an attacker to temporarily control a large amount of capital. This can amplify economic exploits involving flawed pricing, governance assumptions, or accounting logic. The flash-loan mechanism itself is not necessarily a vulnerability; the underlying protocol logic must contain a weakness for the capital to be useful in an attack.

Atomicity is the key property. If an essential step fails, the transaction can revert rather than leaving partially completed operations on-chain. The user can still lose the blockchain transaction fee associated with the failed attempt.