Skip to content

Commit dccc3ff

Browse files
authored
Merge pull request #2387 from blurbeast/docs/audit-prep
docs: add AUDIT_PREP.md checklist for security audits
2 parents 7d8b63e + e5a8191 commit dccc3ff

3 files changed

Lines changed: 75 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ npm run dev
7878
- [`docs/README.md`](docs/README.md): Full documentation index — **start here**.
7979
- [`docs/contracts/contributor-guide.md`](docs/contracts/contributor-guide.md): Contract contributor guide (module layout, lifecycle, error/event stability contracts, test patterns, WASM budget).
8080
- [`quicklendx-backend/docs/contributor-guide.md`](quicklendx-backend/docs/contributor-guide.md): Backend contributor guide (module layout, request pipeline, export/audit wiring, how to add an endpoint).
81+
- [`docs/AUDIT_PREP.md`](docs/AUDIT_PREP.md): Security audit preparation checklist for contributors.
8182
- [Default Flow Diagram](docs/DEFAULT_FLOW_DIAGRAM.md): State-machine diagram from invoice past-due through default to recovery — grace period, finality guards, dispute interception, and a concrete ledger-timestamp walkthrough.
8283
- [`docs/INVOICE_LIFECYCLE_DIAGRAM.md`](docs/INVOICE_LIFECYCLE_DIAGRAM.md): Full invoice state machine — all statuses, transitions, entrypoints, and invariants in one diagram. Start here when debugging invoice state issues. Closes #1946.
8384
- [`docs/OFF_CHAIN_SIGNATURES.md`](docs/OFF_CHAIN_SIGNATURES.md): Threat model and implementation notes for every off-chain signed operation (KYC payloads, cursor attestations, dispute evidence). Closes #1894.

docs/AUDIT_PREP.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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.

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
| [storage-schema.md](contracts/storage-schema.md) | Persistent storage keys and index layout |
2727
| [backup.md](contracts/backup.md) | Backup and restore |
2828
| [audit.md](contracts/audit.md) | Audit trail and hash chain |
29+
| [AUDIT_PREP.md](AUDIT_PREP.md) | Security audit preparation checklist for contributors |
2930
| [CROSS_INVOICE_ANALYTICS.md](CROSS_INVOICE_ANALYTICS.md) | Cross-invoice read patterns, supported entrypoints, and pagination bounds for contributors and integrators |
3031
| [QLX_REPORT_LIFECYCLE.md](QLX_REPORT_LIFECYCLE.md) | Analytics report lifecycle — Requested → Delivered → Archived, entrypoints, storage layout, and invariants |
3132
| [QLX_RISK_PARAMETERS.md](QLX_RISK_PARAMETERS.md) | Complete catalog of risk-related parameters with min/max/default values — investor tiers, business supply limits, bid controls, fee ceilings, and operational bounds |

0 commit comments

Comments
 (0)