This document outlines the security measures, audit status, and best practices for the JustFlash Protocol.
All external entry points are protected with OpenZeppelin's ReentrancyGuard:
contract FlashLoanPool is ReentrancyGuard { function flashLoan(...) external nonReentrant { ... } function deposit(...) external nonReentrant { ... } function withdraw(...) external nonReentrant { ... } }
All functions follow the CEI pattern:
function flashLoan(...) external nonReentrant { // CHECKS: Validate inputs if (amount == 0) revert ZeroAmount(); if (!_supportedTokens[token]) revert TokenNotSupported(token); // EFFECTS: Update state uint256 premium = calculatePremium(amount); uint256 preBalance = getBalance(); // INTERACTIONS: External calls last token.transfer(receiver, amount); receiver.executeOperation(...); token.transferFrom(receiver, address(this), amountOwed); }
Only verified tokens are supported to prevent malicious token attacks:
mapping(address => bool) private _supportedTokens; function whitelistToken(address token) external onlyOwner { _supportedTokens[token] = true; }
Post-callback balance verification ensures repayment:
uint256 postBalance = token.balanceOf(address(this)); if (postBalance < preBalance + premium) { revert FlashLoanRepaymentFailed(...); }
Admin functions are protected with Ownable:
function setFlashLoanFee(uint256 newFee) external onlyOwner { ... } function whitelistToken(address token) external onlyOwner { ... } function setFeeCollector(address collector) external onlyOwner { ... }
| Attack | Description | Mitigation |
|---|---|---|
| Reentrancy | Re-entering functions during execution | nonReentrant modifier |
| Flash Loan Chaining | Manipulating pool during callback | Balance verification |
| Malicious Token | Token with transfer hooks | Token whitelist |
| Integer Overflow | Arithmetic overflow | Solidity 0.8+ native checks |
| Unauthorized Access | Calling admin functions | onlyOwner modifier |
| Griefing | DOS through failed transactions | Gas-efficient design |
JustFlash does not use price oracles for core functionality. Strategies using flash loans (arbitrage, liquidations) may depend on external oracles - this is the user's responsibility.
The owner can:
- Add/remove supported tokens
- Update flash loan fee (max 1%)
- Update fee collector address
- Update treasury address
Consider implementing a timelock or multi-sig for production.
Initial deployment is owner-controlled. Plan to transition to:
- Multi-signature wallet
- Governance contract
- Timelock for sensitive operations
- Internal Review: Completed ✅
- External Audit #1: Pending
- External Audit #2: Pending
- Formal Verification: Pending
- Bug Bounty Program: Pending
- Trail of Bits
- OpenZeppelin
- Consensys Diligence
- Certora (formal verification)
| Severity | Reward Range | Examples |
|---|---|---|
| Critical | 25,000ドル - 100,000ドル | Drain funds, bypass repayment |
| High | 10,000ドル - 25,000ドル | Steal fees, unauthorized admin |
| Medium | 2,500ドル - 10,000ドル | DOS, incorrect fee calculation |
| Low | 500ドル - 2,500ドル | Gas inefficiency, minor issues |
In scope:
- FlashLoanPool.sol
- FeeCollector.sol
- PoolRegistry.sol
- All interface contracts
Out of scope:
- Frontend application
- Third-party integrations
- Issues in dependencies
function executeOperation(...) external returns (bool) { require(msg.sender == FLASH_LOAN_POOL, "Unauthorized"); // ... }
using SafeERC20 for IERC20; // Instead of token.transfer(to, amount); // Use token.safeTransfer(to, amount);
require(amount > 0, "Zero amount"); require(receiver != address(0), "Zero address"); require(premium <= maxAcceptablePremium, "Premium too high");
uint256 received = dex.swap(tokenIn, tokenOut, amountIn); require(received >= minAmountOut, "Slippage exceeded");
pool.flashLoan(...).send({ feeLimit: 500_000_000 }); // 500 TRX
The protocol can be paused by:
- Delisting all tokens (prevents new flash loans)
- Deploying upgraded contracts
- Migrating liquidity
- Detection: Monitor events and balances
- Assessment: Determine impact and scope
- Containment: Delist affected tokens
- Remediation: Deploy fix
- Communication: Notify users
- Post-mortem: Document lessons learned
For security concerns, contact:
- Security Email: security@justflash.io
- GitHub Security Advisory: Submit privately on GitHub
This document is for informational purposes only and does not constitute a security guarantee.