This document describes the security model for contracts/credit, including
actors, trust boundaries, assumptions, and expected failure modes.
In-scope:
Creditcontract state transitions and authorization checks.- Interactions with an external token contract during draw flows.
- Admin-operated configuration endpoints and operational controls.
Out-of-scope:
- Off-chain risk engine correctness.
- Wallet/device security of protocol operators and borrowers.
- Chain-level consensus failures.
- Preserve correctness of borrower credit state (
credit_limit,utilized_amount,status). - Prevent unauthorized administrative changes.
- Prevent borrowers from drawing beyond allowed limits.
- Ensure failed external token operations do not leave partial on-chain state changes.
- Admin (trusted operator)
Can configure liquidity/token settings and perform privileged line management. - Borrower (partially trusted user)
Can draw and repay only against their own credit line. - Indexer / Observer (untrusted reader)
Reads state and events, cannot mutate contract state. - Token contract (external dependency)
Invoked during draw path for reserve checks and token transfer. - Soroban runtime / ledger (trusted platform assumption)
Provides transaction atomicity, auth primitives, and deterministic execution.
Critical assets:
- Contract admin authority.
- Borrower credit line records in persistent storage.
- Liquidity configuration (token contract address, reserve/source address).
Key invariants:
utilized_amountnever exceedscredit_limit.utilized_amountnever drops below zero.- Closed lines cannot be drawn or repaid.
- Only authorized roles perform admin actions.
- Borrower authorization is required on borrower-driven write paths.
- Admin authorization is required on admin-only paths.
- Any missing/incorrect authorization is treated as a hard failure.
- Draw path depends on token contract behavior for
balanceandtransfer. - Assumption: token implements expected Soroban token semantics.
- If token call fails, transaction reverts atomically.
- Admin key custody and operational discipline directly affect security.
- Misconfiguration (wrong token/source) can halt or misroute liquidity.
Threat: attacker attempts to set config or mutate credit lines without admin rights.
Mitigation: admin-only paths require admin auth.
Residual risk: admin private key compromise bypasses this control.
Threat: attacker repays/draws for another borrower or manipulates line lifecycle.
Mitigation: borrower-driven methods require borrower auth and use borrower-keyed records.
Threat: external contract call causes reentrant execution and state corruption.
Mitigation: explicit reentrancy guard on draw/repay critical paths (defense-in-depth).
Assumption: standard token contracts do not callback into caller.
Threat: configured token contract lies about balances, has unexpected behavior, or blocks transfers.
Mitigation:
- token trust is explicit and administrative;
- failed token operations revert transaction atomically;
- operationally restrict token allowlist to vetted contracts.
Residual risk: if admin configures a malicious token, integrity/liveness can be degraded.
Threat: compromised admin key changes config, force-closes lines, or defaults borrowers.
Impact: full protocol control loss for this deployment.
Mitigations (operational):
- hardware-backed/multisig admin account;
- strict key rotation and break-glass procedure;
- on-chain monitoring/alerts for admin method calls.
Threats:
- Wrong liquidity source address.
- Inadequate reserve balance.
- Stale operational processes (no monitoring).
Mitigations:
- pre-deployment and post-change checklist;
- automated reserve health checks;
- incident runbooks and rollback plans for config mistakes.
Current posture: assume immutable deployment unless a separate governance or migration process is explicitly introduced.
Implications:
- Code defects require contract migration to a new deployment.
- Security hotfixes are operationally heavier than in upgradeable architectures.
- Documentation and runbooks must include migration procedures.
Recommended operational policy:
- treat contract release as immutable,
- maintain tested migration scripts,
- announce and execute controlled migration if critical issues are found.
- Soroban authorization and transaction atomicity are correct.
- Token contract follows expected token interface semantics.
- Admin keys are protected by strong operational controls.
- Off-chain risk decisions are sane and not adversarial.
- Fail-closed: unauthorized calls, invalid state transitions, or failing token calls revert.
- Liveness degradation: low reserve or token misbehavior can block draws.
- Governance failure: admin compromise can cause protocol-wide misuse.
- Recommended before production: independent review focused on auth boundaries, external token trust assumptions, and admin key operational controls.
- Re-run threat model on each material contract behavior change.