Threat Model
Detailed analysis of attack surfaces and mitigations.
Adversary Model
Capabilities
| Capability | Description | Risk Level |
|---|---|---|
| Arbitrary Transactions | Can submit any valid Solana tx | High |
| Sybil Accounts | Can create unlimited wallets | Medium |
| Flash Loans | Large capital for single tx | Medium |
| MEV Extraction | Frontrun/sandwich attacks | Medium |
| Market Manipulation | Trade to move prices | Medium |
Limitations
| Limitation | Assumption | Confidence |
|---|---|---|
| Forge Signatures | Ed25519 secure | Very High |
| Break Pyth | Oracle honest | High |
| Control Solana | Network honest | High |
| Infinite Capital | Finite per tx | High |
Attack Surfaces
1. Instruction-Level Attacks
| Instruction | Attack Vector | Mitigation |
|---|---|---|
| create_market | Spam creation | Rent cost limits |
| place_order | Orderbook manipulation | Solvency constraints |
| place_order | Self-trade wash | Self-trade prevention |
| cancel_order | Unauthorized cancel | Owner signature |
| snapshot_* | Oracle manipulation | Pyth security |
| resolve_market | Wrong outcome | Deterministic logic |
| settle_position | Double claim | Settled flag |
| close_market | Premature close | All-settled check |
2. Economic Attacks
| Attack | Description | Mitigation |
|---|---|---|
| Naked Short | Sell without owning | Balance validation |
| Undercollateralized Buy | Buy without funds | Collateral locking |
| Oracle Front-running | Trade on future prices | Pyth latency |
| Market Corner | Accumulate to manipulate | No position limits (v1) |
3. Protocol-Level Attacks
| Attack | Description | Mitigation |
|---|---|---|
| Reentrancy | Callback during execution | Solana locks, no callbacks |
| Integer Overflow | Arithmetic overflow | Checked math |
| PDA Collision | Same PDA, different purpose | Unique seed prefixes |
| Account Confusion | Wrong account type | Discriminator checks |
| Rent Drain | Force account closure | Rent-exempt accounts |
4. Operational Attacks
| Attack | Description | Mitigation |
|---|---|---|
| Crank DoS | Prevent lifecycle | Multiple operators |
| Treasury Drain | Exhaust crank rewards | Capped rewards |
| State Bloat | Create many accounts | Rent costs |
Detailed Mitigations
Reentrancy Protection
Solana's runtime provides inherent protection:
- Account Locking: All accounts locked for transaction
- No Recursive CPI: Cannot borrow mutably twice
- No Token Callbacks: Unlike ERC-777, SPL Token has no hooks
- Idempotency: Settlement checks
settledflag first
Oracle Security
Price validation:
fn validate_price(price: &PythPrice, boundary: i64) -> Result<()> {
// Positive price
require!(price.price > 0, Error::InvalidPrice);
// Published after boundary
require!(price.publish_time >= boundary, Error::StaleOracle);
// Optional confidence check
if max_confidence_ratio > 0 {
let ratio = price.conf * 10000 / price.price.abs();
require!(ratio <= max_confidence_ratio, Error::ConfidenceTooWide);
}
Ok(())
}
Solvency Enforcement
Invariant:
vault.balance >= max(total_yes_shares, total_no_shares)
Audit Findings
Finding 1: Oracle Price Staleness
Concern: Stale Pyth prices could affect resolution.
Status: Mitigated
Mitigation: Sampling Rule A enforces:
- Start snapshot:
publish_time >= t_start - End snapshot:
publish_time >= t_end
Finding 2: Settlement Double-Claim
Concern: Users could settle multiple times.
Status: Mitigated
Mitigation: Atomic settled flag:
if position.is_settled() {
return Ok(()); // No-op
}
// ... calculate payout ...
position.set_settled();
Finding 3: Crank Liveness
Concern: Markets stall if no cranks available.
Status: Accepted Risk
Rationale:
- Permissionless operation
- Incentivized with rewards
- Multiple operators expected
- Force close fallback
Finding 4: Epoch Boundary Race
Concern: Clock drift at boundaries.
Status: Mitigated
Mitigation: Inclusive bounds (>=) prevent gaps.
Finding 5: Price Conversion Precision
Concern: NO to YES conversion precision loss.
Status: Mitigated
Mitigation:
- Exact integer arithmetic
- Protocol-favorable rounding
- Comprehensive test coverage
Known Limitations (v1)
| Limitation | Description | Future |
|---|---|---|
| No position limits | Unlimited accumulation | Add optional limits |
| Single oracle | Only Pyth | Multi-oracle support |
| 64 order limit | Per side per market | Expand capacity |
| Full collateral | No leverage | Add margin |
Incident Response
Severity Levels
| Level | Description | Response Time |
|---|---|---|
| P0 | Funds at risk | Immediate |
| P1 | Potential loss | < 4 hours |
| P2 | Non-critical | < 24 hours |
| P3 | Minor issue | < 1 week |
Response Procedure
- Detect: Identify the issue
- Assess: Determine severity and scope
- Mitigate: Pause if possible
- Fix: Deploy remediation
- Disclose: Coordinate public disclosure
Next Steps
- Review Invariants for formal guarantees
- See Architecture Security for implementation