This document provides a comprehensive security analysis of the StellarLend protocol's pause mechanism, including trust boundaries, authorization flows, and potential attack vectors.
- Trust Level: Highest
- Capabilities:
- Set/unset any pause flag
- Configure guardian address
- Trigger emergency shutdown
- Control emergency state transitions
- Configure all protocol parameters
- Security Requirements:
- Should be a multisig wallet or DAO-governed address
- Key rotation procedures must be established
- Transaction signing should require multiple approvals
- Trust Level: High (but limited scope)
- Capabilities:
- Trigger emergency shutdown only
- Cannot set pause flags
- Cannot configure protocol parameters
- Cannot initiate recovery procedures
- Security Requirements:
- Should be a security-focused multisig
- Lower latency than admin for emergency response
- Separate from admin to avoid single point of failure
- Trust Level: Medium
- Capabilities:
- Update price feeds
- Independent pause mechanism for oracle operations
- Security Requirements:
- Price feed validation required
- Staleness checks enforced
- Independent authorization from pause system
| Function | Admin | Guardian | Oracle | User | Public |
|---|---|---|---|---|---|
| set_pause | ✓ | ✗ | ✗ | ✗ | ✗ |
| set_guardian | ✓ | ✗ | ✗ | ✗ | ✗ |
| emergency_shutdown | ✓ | ✓ | ✗ | ✗ | ✗ |
| start_recovery | ✓ | ✗ | ✗ | ✗ | ✗ |
| complete_recovery | ✓ | ✗ | ✗ | ✗ | ✗ |
| set_oracle_paused | ✓ | ✗ | ✓ | ✗ | ✗ |
| update_price_feed | ✗ | ✗ | ✓ | ✗ | ✗ |
| get_pause_state | ✗ | ✗ | ✗ | ✗ | ✓ |
| get_emergency_state | ✗ | ✗ | ✗ | ✗ | ✓ |
- Impact: Blocks all operations except admin functions
- Use Case: Extreme emergency, protocol upgrade
- Security Notes:
- Overrides all individual pause flags
- Cannot be bypassed by any user operation
- Requires explicit admin action to disable
- Impact: Prevents new collateral from entering protocol
- Use Case: Suspicious deposit patterns, oracle issues
- Security Notes:
- Blocks both
depositanddeposit_collateral - Does not affect existing positions
- Can be used to limit protocol exposure
- Blocks both
- Impact: Prevents new loan origination
- Use Case: Liquidity concerns, market volatility
- Security Notes:
- Blocks new risk but allows existing operations
- Users can still repay and withdraw
- Does not affect existing loan positions
- Impact: Blocks loan repayments (use with caution)
- Use Case: Critical bug in repayment logic
- Security Notes:
- Dangerous - prevents debt reduction
- Should only be used in extreme circumstances
- Can trap users in debt positions
- Impact: Prevents collateral withdrawal
- Use Case: Insufficient liquidity, suspected manipulation
- Security Notes:
- Blocks user access to their collateral
- Can be used to prevent bank runs
- Must be used carefully to maintain user trust
- Impact: Prevents liquidation of unhealthy positions
- Use Case: Liquidation bug, market manipulation
- Security Notes:
- Can increase protocol risk if used improperly
- Allows unhealthy positions to remain
- Should be temporary with clear exit strategy
- All operations available subject to individual pause flags
- Standard security checks apply
- No additional restrictions
- All user operations blocked regardless of pause flags
- Only admin functions available
- Maximum security posture
- Recovery requires admin action
- Unwind operations allowed (repay, withdraw)
- New risk operations blocked (borrow, deposit)
- Granular pause flags still respected
- Controlled protocol exit
Risk: Critical Impact: Complete protocol control Mitigation:
- Multisig admin wallet
- Regular key rotation
- Time-locked critical operations
- Guardian as backup
Risk: High Impact: Emergency shutdown capability Mitigation:
- Separate security team
- Limited scope (shutdown only)
- Cannot access funds or change settings
- Rapid detection and response
Risk: Medium Impact: Service disruption Mitigation:
- Admin authorization required
- Event emission for monitoring
- Clear documentation of pause reasons
Risk: Medium Impact: Fund lockup Mitigation:
- Recovery mode provides exit path
- Admin can always return to normal
- Guardian cannot prevent recovery
Risk: Medium Impact: Incorrect liquidations/borrows Mitigation:
- Independent oracle pause mechanism
- Staleness checks
- Price validation
- Multiple oracle sources
All pause checks occur before any state modifications:
// Pattern used throughout contract
if is_paused(&env, PauseType::Operation) || blocks_high_risk_ops(&env) {
return Err(ErrorType::ProtocolPaused);
}
// Then proceed with operation logic- Flash loans have dedicated reentrancy guards
- Pause checks occur before reentrancy protection
- Global pause blocks flash loans
- Individual pauses do not affect flash loans
- pause_event: Emitted on any pause state change
- guardian_set_event: Emitted when guardian is configured
- emergency_state_event: Emitted on emergency state transitions
- Real-time alerting for all pause events
- Guardian activity monitoring for early threat detection
- Emergency state tracking for protocol health
- Admin action logging for audit trails
- Use multisig wallets with required signatures
- Implement time delays for critical operations
- Maintain clear audit trails
- Regular security reviews
- Separate security team from admin team
- Regular guardian rotation
- Clear escalation procedures
- Backup guardian mechanisms
- Document reasons for all pause actions
- Set clear timeframes for pause duration
- Communicate pause status to users
- Have unpause procedures ready
- Test emergency shutdown procedures regularly
- Maintain communication channels
- Have recovery plans documented
- Coordinate with external stakeholders
- Individual pause flags for all operations
- Global pause override behavior
- Cross-asset operation pause testing
- Oracle pause independence
- Emergency state transitions
- Unauthorized access attempts
- Zero amount edge cases
- Comprehensive matrix testing
- Authorization boundary testing
- Pause flag independence verification
- Emergency state behavior validation
- Reentrancy protection confirmation
- Event emission verification
- Implement multisig admin if not already done
- Configure guardian with security team
- Set up monitoring for pause events
- Document emergency procedures
- Time-locked admin operations for critical changes
- Decentralized guardian system
- Automated pause detection and response
- Regular security audits of pause mechanism
The pause mechanism provides robust security controls for the StellarLend protocol. When properly configured with multisig admin and independent guardian, it offers multiple layers of protection against various attack vectors. The comprehensive test matrix ensures all pause scenarios are covered, and the event-driven architecture enables proper monitoring and response.
The system balances security with usability, allowing for emergency response while maintaining user access to funds during recovery periods. Regular testing and monitoring are essential to maintain the security guarantees provided by this mechanism.