Lending & Borrowing Auditor
When to Use
- Auditing lending/borrowing protocols, collateral management systems
- User mentions: lending, borrowing, liquidation, collateral, loan, repayment, refinancing, debt, grace period, pause mechanism
- Analyzing loan lifecycle: creation, repayment, liquidation, refinancing
- Reviewing collateral tracking, debt calculations, pause/unpause operations
Audit Workflow
IMPORTANT: Announce skill usage at the start of analysis
Begin with: "I'm using the audit-lending skill to analyze this contract for lending and borrowing protocol vulnerabilities..."
Scan for lending operations
- Search:
liquidate, repay, borrow, collateral, loan, refinance, close, pause, unpause
- Focus: liquidation conditions, collateral management, debt tracking, pause mechanisms
Check against vulnerability patterns
- Reference
reference.md for complete checklist
- Compare code against
example.md
Validate exploitability
- Check access control first - grep for
onlyOwner|onlyAdmin|onlyGovernance modifiers
- Can non-privileged actors exploit lending vulnerabilities?
- Can borrower avoid liquidation?
- Can attacker grief lenders/borrowers?
- Can loan state be corrupted?
- Verify no compensating protections exist
- Downgrade severity if admin-only unless direct user fund impact
Generate report
- Use deliverable template below
- Include PoC for each finding
- Rank by severity
Core Vulnerability Patterns
See reference.md for full checklist. Key patterns:
- Liquidation before default → borrowers unfairly liquidated early
- Collateral manipulation → prevents liquidation entirely
- Loan closure without repayment → debt written off
- Asymmetric pause mechanism → repayments paused, liquidations active
- Token disallow blocks existing operations → repayments/liquidations fail
- No grace period after unpause → immediate unfair liquidations
- Incorrect liquidation shares → collateral drained with partial repayment
- Repayments to zero address → funds burned
- Forced loan assignment → unwilling lenders receive loans
- Loan state manipulation → auction cancellation extends loans indefinitely
- Double debt subtraction → pool balance corrupted
- Dust loan griefing → bypass minLoanSize to force small loans
Code examples: See example.md
Severity Criteria
Critical: Fund loss, collateral theft, debt erasure without repayment, pool insolvency, MUST be exploitable by non-privileged actors
High: Unfair liquidation, griefing preventing operations, loan state corruption enabling extended default, MUST be exploitable by non-privileged actors
Medium: Edge case timing issues, suboptimal pause mechanisms, dust attacks with limited impact, admin-only lending configuration issues with cascading user impact
Low: Inefficient implementations without security impact, admin-only parameter issues without immediate user impact
IMPORTANT: Admin-only lending functions (onlyOwner, onlyAdmin, onlyGovernance) are MEDIUM or LOW severity unless:
- Invalid parameters directly enable borrowers to avoid repayment or liquidation
- Missing validation enables admin to steal user collateral or erase debt without authorization
- Pause mechanism asymmetry (admin pauses repayments but not liquidations) directly harms borrowers
False Positives - Do NOT Flag
- Liquidation timing with documented grace periods
- Admin-only token disallow for new loans (not affecting existing)
- Intentional minimum loan sizes with explicit documentation
- Refinancing with proper accounting checks
- Pause mechanisms affecting both repayment and liquidation symmetrically
- Admin-only collateral configuration functions (onlyOwner, onlyAdmin) with documented trust assumptions
- Governance-controlled loan parameter updates with timelock allowing users to exit
- Admin functions for emergency pause where both repayment and liquidation are halted symmetrically
Deliverable Format
MANDATORY: Before deliverable, verify each checklist.md item against codebase. Flag violations as findings.
Use template: templates/report-template.md
Each finding includes: severity, pattern #, file/lines, description, vulnerable code, impact analysis, PoC showing exploitation, remediation, gas impact.
Key Principles
- Grace periods - borrowers need reasonable time after defaults/unpauses
- Symmetric pauses - pause repayments → pause liquidations
- Collateral integrity - cannot be zeroed or manipulated post-creation
- Accurate accounting - debt tracking must be atomic and correct
- Minimum viability - enforce minimums to prevent griefing
Output Guidelines
DO:
- Reference specific lines and functions
- Provide executable PoCs showing fund loss or griefing
- Quantify impact (funds at risk, borrowers affected)
- Show timing calculations for liquidation conditions
DON'T:
- Report intentional design choices with documentation
- Flag gas optimizations without exploit path
- Use vague terms ("could be vulnerable")
- Ignore context (grace periods elsewhere, admin controls)
1---2name: audit-lending3description: Audits Solidity lending and borrowing protocols for vulnerabilities including premature liquidation before default, collateral manipulation preventing liquidation, loan closure without repayment, asymmetric pause mechanisms, token disallowance blocking operations, missing grace periods, incorrect liquidation share calculations, repayments to zero address, forced loan assignments, loan state manipulation via refinancing, double debt accounting, and dust loan griefing attacks4license: MIT5---67# Lending & Borrowing Auditor89## When to Use10- Auditing lending/borrowing protocols, collateral management systems11- User mentions: lending, borrowing, liquidation, collateral, loan, repayment, refinancing, debt, grace period, pause mechanism12- Analyzing loan lifecycle: creation, repayment, liquidation, refinancing13- Reviewing collateral tracking, debt calculations, pause/unpause operations1415## Audit Workflow1617**IMPORTANT: Announce skill usage at the start of analysis**1819Begin with: "I'm using the **audit-lending** skill to analyze this contract for lending and borrowing protocol vulnerabilities..."20211. **Scan for lending operations**22 - Search: `liquidate`, `repay`, `borrow`, `collateral`, `loan`, `refinance`, `close`, `pause`, `unpause`23 - Focus: liquidation conditions, collateral management, debt tracking, pause mechanisms24252. **Check against vulnerability patterns**26 - Reference `reference.md` for complete checklist27 - Compare code against `example.md`28293. **Validate exploitability**30 - **Check access control first** - grep for `onlyOwner|onlyAdmin|onlyGovernance` modifiers31 - Can non-privileged actors exploit lending vulnerabilities?32 - Can borrower avoid liquidation?33 - Can attacker grief lenders/borrowers?34 - Can loan state be corrupted?35 - Verify no compensating protections exist36 - Downgrade severity if admin-only unless direct user fund impact37384. **Generate report**39 - Use deliverable template below40 - Include PoC for each finding41 - Rank by severity4243## Core Vulnerability Patterns4445See `reference.md` for full checklist. Key patterns:46471. Liquidation before default → borrowers unfairly liquidated early482. Collateral manipulation → prevents liquidation entirely493. Loan closure without repayment → debt written off504. Asymmetric pause mechanism → repayments paused, liquidations active515. Token disallow blocks existing operations → repayments/liquidations fail526. No grace period after unpause → immediate unfair liquidations537. Incorrect liquidation shares → collateral drained with partial repayment548. Repayments to zero address → funds burned559. Forced loan assignment → unwilling lenders receive loans5610. Loan state manipulation → auction cancellation extends loans indefinitely5711. Double debt subtraction → pool balance corrupted5812. Dust loan griefing → bypass minLoanSize to force small loans5960**Code examples:** See `example.md`6162## Severity Criteria6364**Critical:** Fund loss, collateral theft, debt erasure without repayment, pool insolvency, **MUST be exploitable by non-privileged actors**65**High:** Unfair liquidation, griefing preventing operations, loan state corruption enabling extended default, **MUST be exploitable by non-privileged actors**66**Medium:** Edge case timing issues, suboptimal pause mechanisms, dust attacks with limited impact, **admin-only lending configuration issues with cascading user impact**67**Low:** Inefficient implementations without security impact, **admin-only parameter issues without immediate user impact**6869**IMPORTANT:** Admin-only lending functions (onlyOwner, onlyAdmin, onlyGovernance) are **MEDIUM or LOW severity** unless:70- Invalid parameters directly enable borrowers to avoid repayment or liquidation71- Missing validation enables admin to steal user collateral or erase debt without authorization72- Pause mechanism asymmetry (admin pauses repayments but not liquidations) directly harms borrowers7374## False Positives - Do NOT Flag7576- Liquidation timing with documented grace periods77- Admin-only token disallow for new loans (not affecting existing)78- Intentional minimum loan sizes with explicit documentation79- Refinancing with proper accounting checks80- Pause mechanisms affecting both repayment and liquidation symmetrically81- **Admin-only collateral configuration functions** (onlyOwner, onlyAdmin) with documented trust assumptions82- Governance-controlled loan parameter updates with timelock allowing users to exit83- Admin functions for emergency pause where both repayment and liquidation are halted symmetrically8485## Deliverable Format8687**MANDATORY:** Before deliverable, verify each `checklist.md` item against codebase. Flag violations as findings.8889Use template: `templates/report-template.md`9091Each finding includes: severity, pattern #, file/lines, description, vulnerable code, impact analysis, PoC showing exploitation, remediation, gas impact.9293## Key Principles9495- **Grace periods** - borrowers need reasonable time after defaults/unpauses96- **Symmetric pauses** - pause repayments → pause liquidations97- **Collateral integrity** - cannot be zeroed or manipulated post-creation98- **Accurate accounting** - debt tracking must be atomic and correct99- **Minimum viability** - enforce minimums to prevent griefing100101## Output Guidelines102103**DO:**104- Reference specific lines and functions105- Provide executable PoCs showing fund loss or griefing106- Quantify impact (funds at risk, borrowers affected)107- Show timing calculations for liquidation conditions108109**DON'T:**110- Report intentional design choices with documentation111- Flag gas optimizations without exploit path112- Use vague terms ("could be vulnerable")113- Ignore context (grace periods elsewhere, admin controls)