This document outlines the threat model for the Spark ALM Controller, including attack vectors, trust assumptions, and mitigations.
| Actor | Trust Level | Description |
|---|---|---|
Governance (DEFAULT_ADMIN_ROLE) |
Fully trusted | Controls all admin functions, can upgrade controllers, set rate limits |
Relayer (RELAYER) |
Untrusted | Assumed to be potentially compromised at any time |
Freezer (FREEZER) |
Trusted | Emergency response role, can remove compromised relayers |
| External Protocols | Varies | Trust depends on specific integration (see Protocol Trust section) |
Assumption: All stablecoin assets are treated as 1:1 with each other (USDC = USDT = DAI = USDS).
Implication: No price oracles are used for stablecoin swaps within the system.
Risk: If assets depeg significantly, the 1:1 assumption breaks down. This is an accepted protocol risk that should be monitored operationally.
The system is designed with the assumption that a RELAYER can be fully compromised by a malicious actor. This is the primary threat the architecture defends against.
| Attack | Mitigation |
|---|---|
| Unauthorized fund transfer | Funds can only move to whitelisted addresses; rate limits bound exposure |
| Excessive slippage attacks | maxSlippage parameters enforce minimum acceptable returns |
| Rate limit exhaustion | Rate limits regenerate over time; bounded maximum exposure |
| Interaction with malicious contracts | Rate limit keys act as whitelist - only configured integrations work |
| DOS attacks | Accepted risk; recovery procedures documented in Attacks.t.sol |
| Gas griefing | Accepted risk; economic impact is minimal compared to rate-limited capital |
-
Value cannot leave the system - All operations must keep funds within the ALM system of contracts
- Exception: Asynchronous integrations (e.g., BUIDL, Ethena) where funds go to whitelisted addresses
-
Losses bounded by rate limits - Any single attack is limited to the current rate limit capacity
-
Freezer can halt attacks - The
FREEZERrole can remove a compromised relayer within the rate limit window -
No trust in relayer input - All relayer-provided parameters are validated against on-chain constraints
Rate limits serve as the primary security boundary against compromised relayers.
- Immediate attack capacity =
lastAmountplus accumulation sincelastUpdated(current available limit) - Maximum attack capacity =
maxAmount(rate limit ceiling) - Recovery rate =
slope(tokens per second regeneration)
Rate limit keys (hash of function identifier + address) act as an implicit whitelist:
- Only governance-configured integrations have valid rate limit keys
- Attempting to use unconfigured addresses will revert
- Provides protection against interaction with malicious contracts
| Protocol | Trust Reason |
|---|---|
| Sky Allocation System | Core protocol, governance controlled |
| PSM | Core protocol, immutable |
| Protocol | Caveat |
|---|---|
| Ethena | Delegated signer can be set by relayer; Ethena's off-chain validation trusted |
| EtherFi | Withdrawal requests can be invalidated (and revalidated) by admin |
| OTC Desks | Assumed to complete trades; max loss bounded by single swap amount |
| Maple | Permissioned pools with slower dynamics |
| Protocol | Risk | Mitigation |
|---|---|---|
| ERC-4626 Vaults | Rounding/donation attacks | Require burned shares; maxExchangeRate mechanism |
| Curve Pools | Unseeded pool manipulation | Require pools to be seeded before whitelisting |
| CCTP | Bridge delays | Operational consideration only |
Attack: Attacker gains access to relayer private key
Response:
FREEZERcallsremoveRelayerto revoke access- System switches to backup relayer
- Maximum loss bounded by rate limits at time of compromise
Attack: Compromised relayer repeatedly executes trades at maximum allowed slippage
Response:
- Rate limits bound total value extracted
FREEZERremoves relayer when attack detected- Slippage parameters limit per-transaction loss
Attack: Compromised relayer spams transactions to prevent legitimate operations
Response:
- Accept temporary operational disruption
FREEZERremoves compromised relayer- Resume operations with backup relayer
- Recovery procedures documented in
Attacks.t.sol
Attack: Compromised relayer tries to interact with malicious contract
Response:
- Rate limit key not configured for malicious contract
- Transaction reverts automatically
- No funds at risk
| Item | Rationale |
|---|---|
| Gas costs | Operational expense, not security vulnerability |
| Temporary DOS | Acceptable; recovery procedures exist |
| Slippage within limits | Bounded by configuration; operational cost |
The following invariants must always hold:
- Funds stay in system - ALMProxy balance can only decrease through governance-approved operations
- Rate limits enforced - No operation can exceed its configured rate limit
- Whitelist enforced - Only configured addresses can be interacted with
- Freezer can halt -
FREEZERcan always remove any relayer - Governance supreme -
DEFAULT_ADMIN_ROLEcan always recover funds and reconfigure system
Focus on:
- Rate limit bypass - Can any path avoid rate limit checks?
- Whitelist bypass - Can unconfigured addresses be used?
- Fund extraction - Can funds leave the ALM system unexpectedly?
- Slippage manipulation - Can
maxSlippagechecks be bypassed? - Access control - Are role checks correctly implemented?
Do NOT focus on:
- Gas optimization (unless it affects security)
- DOS prevention (accepted risk, but still preferable to be mitigated if possible)
- Theoretical attacks requiring governance compromise