# Flash Loan Attack Runbook

## Alert: FlashLoanAttemptBlocked

### Severity: CRITICAL

### Description
The FlashLoanGuard has detected and blocked a potential flash loan attack. An attacker attempted to perform critical operations (purchase, mint, or stake) within the same block as obtaining a flash loan.

### Immediate Actions (< 5 minutes)

1. **Assess the Situation**
   - Identify the attacker address from the event
   - Check if any transactions succeeded before the block
   - Verify the FlashLoanGuard is working correctly

2. **Analyze Attack Vector**
   - Review the transaction trace
   - Identify which function was targeted
   - Check for any state changes despite the block

3. **Protective Measures**
   - Consider temporarily pausing if attack is ongoing
   - Monitor the attacker address for further attempts
   - Review related transactions in the same block

### Investigation Checklist

- [ ] Attacker address identified and logged
- [ ] Transaction trace analyzed
- [ ] No funds were lost
- [ ] FlashLoanGuard functioning correctly
- [ ] Check for related addresses (attacker's other wallets)
- [ ] Review if attack pattern is known

### Post-Incident Actions

1. Add attacker address to watchlist
2. Analyze attack pattern for improvements
3. Consider additional protections if new vector found
4. Document the incident for future reference
5. Update threat model if necessary

### Technical Details

The FlashLoanGuard tracks:
- Block number of user's last critical action
- Prevents same-block repeated actions
- Applies to: token purchases, license minting, staking

### Recovery Actions (if bypass discovered)

1. IMMEDIATELY pause all contracts
2. Alert security team
3. Deploy patched FlashLoanGuard
4. Review all transactions since vulnerability introduced
5. Compensate affected users if necessary

### Contacts

- Security Lead: @security-lead
- Smart Contract Team: #smart-contracts
- DeFi Security: @defi-security

### Related Runbooks

- [Large Transaction](./large-transaction.md)
- [Contract Paused](./contract-paused.md)
- [Incident Response Plan](./incident-response.md)
