|
| 1 | +# Security Audit Preparation Checklist |
| 2 | + |
| 3 | +This guide is for **contributors** preparing the QuickLendX Soroban smart contracts for an external security audit. It outlines exactly what to provide to the auditor, what the audit process looks like, and what to verify before handing over the codebase. |
| 4 | + |
| 5 | +## 1. What to Fix Pre-Audit (The Contributor Checklist) |
| 6 | + |
| 7 | +Before creating the audit commit hash, ensure all the following checks pass locally. Do not hand over code with failing tests or unaddressed lints. |
| 8 | + |
| 9 | +### Pass all tests and lints |
| 10 | +```bash |
| 11 | +cd quicklendx-contracts |
| 12 | +# 1. Build for the target architecture |
| 13 | +cargo build --target wasm32-unknown-unknown --release |
| 14 | + |
| 15 | +# 2. Run all tests (including fuzz tests if applicable) |
| 16 | +cargo test --workspace |
| 17 | + |
| 18 | +# 3. Check for any clippy warnings |
| 19 | +cargo clippy --workspace --all-targets -- -D warnings |
| 20 | +``` |
| 21 | + |
| 22 | +### Clean up test code in production paths |
| 23 | +Ensure no `std::` dependencies have leaked into the contract code. The contract must maintain `#![no_std]` discipline. Use `soroban_sdk` primitives exclusively. |
| 24 | + |
| 25 | +### Resolve all TODOs in critical paths |
| 26 | +Search the codebase for `TODO` or `FIXME` and either resolve them or move them to the issue tracker. The auditor will flag unresolved inline TODOs as potential risks. |
| 27 | + |
| 28 | +## 2. What to Hand the Auditor |
| 29 | + |
| 30 | +When engaging the audit firm, provide a single zip file or a direct link to a specific commit hash containing the following: |
| 31 | + |
| 32 | +### Scope Definition |
| 33 | +Clearly define what is in and out of scope. For example: |
| 34 | +- **In Scope:** `quicklendx-contracts/src/**/*.rs` |
| 35 | +- **Out of Scope:** `quicklendx-frontend/`, `quicklendx-backend/` |
| 36 | + |
| 37 | +### The Commit Hash |
| 38 | +Never give a branch name (e.g., `main`). Always provide the exact commit hash: |
| 39 | +`Commit: a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0` |
| 40 | + |
| 41 | +### Generated Documentation |
| 42 | +Point the auditor to the rustdoc output. Provide them with the command to generate it locally: |
| 43 | +```bash |
| 44 | +cargo doc --no-deps --open |
| 45 | +``` |
| 46 | + |
| 47 | +### Architecture and Threat Model Context |
| 48 | +Link the auditors directly to our core design documents: |
| 49 | +- [Invoice Lifecycle Diagram](./INVOICE_LIFECYCLE_DIAGRAM.md) |
| 50 | +- [Default Flow Diagram](./DEFAULT_FLOW_DIAGRAM.md) |
| 51 | +- [Off-Chain Signatures & Threat Model](./OFF_CHAIN_SIGNATURES.md) |
| 52 | + |
| 53 | +## 3. What to Expect During the Audit |
| 54 | + |
| 55 | +### Initial Review & Questions |
| 56 | +Auditors will typically spend the first week reviewing the architecture and asking clarifying questions. Expect them to ask for concrete examples of state transitions. |
| 57 | + |
| 58 | +**Example Auditor Question:** |
| 59 | +> "How does an invoice transition from `Funded` to `Repaid` if the borrower only sends a partial payment?" |
| 60 | +
|
| 61 | +**Example Contributor Response:** |
| 62 | +> "Partial payments do not automatically transition the invoice to `Repaid`. The entrypoint `record_payment(env, invoice_id, amount)` updates the `remaining_balance`. Only when `remaining_balance == 0` does the state machine allow the transition to `Repaid`." |
| 63 | +
|
| 64 | +### Preliminary Report |
| 65 | +You will receive a draft report detailing vulnerabilities categorized by severity (Critical, High, Medium, Low, Informational). |
| 66 | + |
| 67 | +### Remediation Phase |
| 68 | +You will have a window (usually 1-2 weeks) to fix the identified issues. For each finding, you will either: |
| 69 | +1. **Fix the issue:** Submit a PR addressing the vulnerability. |
| 70 | +2. **Acknowledge/Accept the risk:** Provide a documented justification for why the behavior is intended. |
| 71 | + |
| 72 | +### Final Report |
| 73 | +After reviewing your fixes, the auditor will publish the final report, verifying that the critical and high vulnerabilities have been resolved. |
0 commit comments