flash-loan
하는 일
이 플레이북은 플래시 론이 다른 약점을 직접 만들기보다 증폭시키는 방식을 설명합니다. 플래시 론 콜백이나 가격 데이터를 쓰는 DeFi 컨트랙트를 검토하는 감사자를 위한 스킬입니다.
사용하는 경우
- ✓DeFi 컨트랙트가 플래시 론 콜백을 받아들이고 그것을 검토해야 할 때.
- ✓프로토콜의 가격이나 투표가 대출로 잠시 바뀔 수 있는 잔액에 의존할 때.
- ✓실제 대출 없이 콜백이 호출될 수 있는지 확인하고 싶은 경우.
스킬 링크
https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/contracts/flash-loan/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“우리 대출 컨트랙트는 플래시 론 콜백을 처리합니다. 이것이 악용될 수 있는지 확인해 주시겠어요?”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 콜백 검증을 확인하고, 대출이 움직일 수 있는 가격이나 잔액 읽기를 찾으며, 테스트로 결과를 확인합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Flash Loan Attack Playbook
Flash loans give the attacker uncollateralized capital for a single transaction. They're not vulnerabilities themselves — they're a force multiplier for existing bugs. Sources: Aave, Balancer, Uniswap V2/V3, Maker, dYdX (deprecated).
Common attack patterns
1. Oracle amplification (most common)
Use loan to push a price, then trigger price-dependent action.
Cross-reference: see oracle-manipulation/SKILL.md.
2. Unauthenticated callback handler
function executeOperation(
address[] calldata assets,
uint256[] calldata amounts,
uint256[] calldata premiums,
address initiator, // ← UNVALIDATED in many contracts
bytes calldata params
) external returns (bool) {
// Anyone can call this with fake `initiator`
// and have the contract do whatever the params say
}
Bug: initiator and msg.sender == pool checks are missing.
Attack: call executeOperation directly with no actual loan, malicious params → contract does the operation anyway.
3. Governance attack via flash loan
// Vulnerable governance:
function propose() external {
require(getVotes(msg.sender) > THRESHOLD);
// ...
}
function getVotes(address user) public view returns (uint256) {
return token.balanceOf(user); // ← reads SPOT balance, not snapshot
}
Attack: flash-loan governance tokens, propose malicious change (e.g., upgrade contract to drain), vote with the loaned tokens, execute, repay loan. MakerDAO had this pattern; mitigated by checkpoint-based voting.
4. Liquidity manipulation
Pool that uses totalSupply() or balanceOf(pool) for share math:
function deposit(uint256 amt) external {
uint256 shares = (amt * totalSupply()) / underlying.balanceOf(address(this));
_mint(msg.sender, shares);
underlying.transferFrom(msg.sender, address(this), amt);
}
Attacker:
- Flash-loan and deposit (becomes 99% of pool)
- Donate underlying to inflate
underlying.balanceOfartificially - Next depositor's shares =
amt * totalSupply / inflatedBalance≈ 0 - Withdraw → drain
This is the ERC4626 inflation attack (also covered in
reentrancy/overlap).
5. Liquidation arbitrage gone wrong
A liquidator that uses flash loans to repay debt before claiming collateral — usually benign. The bug: liquidation health check happens before the seizure, but the seizure happens via callback into a manipulable function. Reentrancy + oracle dependent.
Audit steps
1. Locate flash-loan integrations
grep -rn 'executeOperation\|flashLoan\|onFlashLoan\|flashCallback\|aaveFlashLoan' src/
2. For each handler
Check:
msg.sender == known_pool(whitelist callback origin)initiator == address(this)(only respond to your own loans)- ReentrancyGuard on the public function that takes the loan
- The fee is correctly accounted (
amounts[i] + premiums[i]is repaid)
3. For each price-reading function
See oracle-manipulation/SKILL.md.
4. For each share-mint / share-burn function
Check ERC4626 virtual-shares mitigation:
// OpenZeppelin ERC4626 v4.7+
function _convertToShares(uint256 assets, MathUpgradeable.Rounding rounding) internal view virtual override returns (uint256) {
return _initialConvertToShares(assets, rounding); // adds 10**18 to total supply for share calc
}
If using legacy ERC4626 or custom vault math, write a Foundry test that:
- Attacker deposits 1 wei → gets 1 share
- Attacker direct-transfers 1e18 underlying to vault
- Victim deposits 1e18 → gets 0 shares (rounding)
- Attacker withdraws 1 share → gets 100% of pool
foundry_inflation_test(vault_address="...", underlying="...", target_path="src/Vault.sol")
Severity calibration
| Pattern | Severity if confirmed |
|---|---|
| Unauth callback handler → arbitrary execution | Critical 10.0 |
| Flash-loan oracle manipulation drains protocol | Critical 9-10 |
| Governance attack possible | Critical 9-10 (if exec results in fund loss) |
| ERC4626 inflation attack on live vault | Critical 9 |
| Liquidation reentrancy via callback | High 8 |
| Theoretical (low liquidity, manipulation cost > attack profit) | Medium-Low |
PoC template (Foundry)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "forge-std/Test.sol";
import "@aave-v3/interfaces/IPool.sol";
contract Test_FlashAttack is Test {
IPool constant AAVE = IPool(0x87870Bca3F3fD63
자주 묻는 질문
플래시 론 자체가 버그인가요?
아닙니다. 플레이북은 플래시 론이 기존 버그를 증폭하는 요인이라고 설명합니다.
흔한 콜백 실수는 무엇인가요?
호출자가 대출 풀인지, 그리고 개시자가 유효한지 확인하지 않는 것입니다.
팀은 이를 어떻게 막나요?
호출자를 검증하고, 현재 잔액이나 가격에 기반한 중요한 결정을 피하는 방식으로 막습니다.
상세 정보
작성자의 원본 설명
Flash-loan exploit patterns — callback reentrancy, oracle amplification, governance attacks, unauthenticated callback handlers.
인기도
- GitHub 스타
- 6.5k
- 순위
- #14007
- 라이선스
- Apache-2.0
- 업데이트
- 2026. 11. 1.
댓글
- …
이 저장소의 다른 스킬
detector-overview
6.5k에이전트가 스캐너가 표시한 코드를 읽고, 표시된 곳 중 어디가 실제 보안 버그이고 어디가 오탐인지 판단하도록 돕습니다.
exploiter-overview
6.5k에이전트가 확인된 여러 보안 약점을 하나의 테스트 체인으로 묶고, 그 체인이 어디까지 닿을 수 있는지 확인하도록 돕습니다.
llm-redteam-overview
6.5k에이전트가 프롬프트 인젝션부터 모델 악용까지 15개 전술 그룹 중 테스트에 맞는 AI 레드팀 가이드를 찾도록 돕습니다.
aatmf-t01-prompt-injection
6.5k숨겨진 지시가 AI 시스템을 덮어쓰려 하는 프롬프트 인젝션을 설명해, 보안 테스터가 이를 점검할 수 있게 합니다.