Introduction
We express our gratitude to the Collafi team for the collaborative engagement that enabled the execution of this dApp Security Assessment.
Backend API for CollaFi, a peer-to-peer NFT-collateralized lending platform on Hedera. Lenders fund HBAR loan offers against NFT collections; borrowers escrow NFTs as collateral and repay with interest, with operator controlled on chain settlement for payouts, liquidations, and collateral claims
Document | |
|---|---|
| Name | dApp Code Review and Security Analysis Report for Collafi |
| Audited By | Mateusz Garncarek |
| Approved By | Abdelfattah Ibrahim |
| Website | https://www.collafi.com/→ |
| Changelog | 30/07/2026 - Preliminary Report |
| 06/08/2026 - Final Report | |
| Platform | Hedera |
| Language | JavaScript (Node.js) |
| Tags | NFT lending DeFi Hedera HBAR NFT collateral P2P lending |
| Methodology | https://docs.hacken.io/methodologies/dapp-audit-methodology→ |
Document
- Name
- dApp Code Review and Security Analysis Report for Collafi
- Audited By
- Mateusz Garncarek
- Approved By
- Abdelfattah Ibrahim
- Website
- https://www.collafi.com/→
- Changelog
- 30/07/2026 - Preliminary Report
- 06/08/2026 - Final Report
- Platform
- Hedera
- Language
- JavaScript (Node.js)
- Tags
- NFT lending DeFi Hedera HBAR NFT collateral P2P lending
Review Scope | |
|---|---|
| Repository | https://github.com/collafi_server→ |
| Commit | 8ec9653 |
Review Scope
- Repository
- https://github.com/collafi_server→
- Commit
- 8ec9653
Audit Summary
The system users should acknowledge all the risks summed up in the risks section of the report
{FindingsVulnSeverityStatusTable}
Documentation quality
Technical description is not provided.
Code quality
Validation applied inconsistently - same data checked in one route, unchecked in another.
No atomic state transitions or idempotency - guards exist in places, but aren't used systematically.
Clean modular structure and centralized config.
Test coverage
Code coverage of the project is 0% The repository contains no test suite, test framework, or test script.
Core lending flows (offer, accept, repay, claim) are not covered with tests.
Negative cases coverage is missed.
Interactions by several users are not tested.
System Overview
CollaFi Server is the backend of a peer-to-peer NFT-collateralized lending protocol on Hedera, exposing a REST API with the following components:
Lending Core - the money moving heart of the system. Lenders create HBAR loan offers against NFT collections; funds move from the lender to the platform operator account on chain at creation.
Operator - the platform's custodial Hedera account that holds all escrowed HBAR and NFTs. Supports primary/backup failover with on-demand asset migration between operator accounts.
Collections - per NFT collection lending terms: loan duration days, lender/borrower fee bps, repay interest bps, treasury interest share, and interest discounts based on NFT holdings. Admin-managed, but created implicitly on first offer.
Auth - passwordless login via Hedera wallet signature (challenge/response), issuing HS256 JWTs with 1-hour expiry. Admin authorization is a boolean claim granted at login against a wallet whitelist. Includes email verification and X account linking via OAuth 2.0 with PKCE.
Rewards & Quests - a points ledger crediting per-HBAR rates for lending actions (offer create, accept, repay, claim) and fixed points for quests (X follow/like/repost/reply, email verification). Points are spent in an NFT reward shop fulfilled from the rewards wallet. Includes public leaderboards.
Marketplace Proxies - server-side relays for Sentx and Kabila floor-price data using the platform's API keys.
Admin - settings, collection CRUD, blacklist management, points adjustment, and a danger-zone operator promotion endpoint.
It has the following attributes:
Stack: Node.js, Express, Prisma ORM, PostgreSQL
Chain: Hedera — HBAR and HTS NFTs; mirror node for reads, SDK for writes
Auth: wallet-signature challenge JWT
Custody: all user funds/collateral held by the operator account
External services: X API (OAuth 2.0).
Findings
Code ― | Title | Status | Severity | |
|---|---|---|---|---|
| F-2026-1827 | The authenticating accountId is never canonicalized, one wallet becomes many platform identities | fixed | High | |
| F-2026-1827 | Reward points can be spent twice across two different rewards | fixed | High | |
| F-2026-1827 | POST /offers/accept pays out and escrows before the atomic claim | fixed | High | |
| F-2026-1827 | Bulk claim of repaid loans pays the lender twice because each update lacks a status guard | fixed | High | |
| F-2026-1826 | Concurrent claim of a repaid loan pays the lender twice | fixed | High | |
| F-2026-1826 | Concurrent bulk rescind refunds the lender twice | fixed | High | |
| F-2026-1826 | Concurrent offer rescind refunds the lender twice | fixed | High | |
| F-2026-1825 | Reflected XSS in X OAuth callback via unescaped error query param | fixed | High | |
| F-2026-1825 | Hardcoded default JWT secret allows forging any user or admin token | fixed | High | |
| F-2026-1827 | Rescind racing accept deletes an active loan through the cascade after paying twice | fixed | High |
Appendix 1. Severity Definitions
Findings are categorized based on their potential impact and assigned a severity level using the Common Vulnerability Scoring System (CVSS) version 4.0: →
Severity | Description |
|---|---|
Critical | These issues present a major security vulnerability that poses a severe risk to the system. They require immediate attention and must be resolved to prevent a potential security breach or other significant harm. |
High | These issues present a significant risk to the system, but may not require immediate attention. They should be addressed in a timely manner to reduce the risk of the potential security breach. |
Medium | These issues present a moderate risk to the system and cannot have a great impact on its function. They should be addressed in a reasonable time frame, but may not require immediate attention. |
Low | These issues present no risk to the system and typically relate to the code quality problems or general recommendations. They do not require immediate attention and should be viewed as a minor recommendation. |
Severity
- Critical
Description
- These issues present a major security vulnerability that poses a severe risk to the system. They require immediate attention and must be resolved to prevent a potential security breach or other significant harm.
Severity
- High
Description
- These issues present a significant risk to the system, but may not require immediate attention. They should be addressed in a timely manner to reduce the risk of the potential security breach.
Severity
- Medium
Description
- These issues present a moderate risk to the system and cannot have a great impact on its function. They should be addressed in a reasonable time frame, but may not require immediate attention.
Severity
- Low
Description
- These issues present no risk to the system and typically relate to the code quality problems or general recommendations. They do not require immediate attention and should be viewed as a minor recommendation.
Appendix 2. Scope
The scope of the project includes the following endpoints from the provided repository:
Public:
GET /activity/public
POST /auth/challenge
POST /admin/auth/challenge
POST /auth/verify
POST /admin/auth/verify
GET /collections
GET /stats/public
GET /leaderboard/lending
GET /leaderboard/collections
GET /marketplace/kabila-floor
GET /marketplace/sentx-floor
GET /offers/collection
GET /quests/x/callback
GET /rewards/public
GET /settings/public
ALL /api/uploadthing
Authenticated:
POST /auth/profile
POST /auth/profile-image
GET /auth/me
POST /auth/verify-email-code
GET /loans/association-status
POST /loans
GET /loans/accepted
GET /loans/lender
POST /loans/:id/repay
POST /loans/repay-bulk
POST /loans/:id/claim
POST /loans/claim-bulk
GET /notifications
POST /notifications/read-all
GET /offers
GET /offers/interest-split
POST /offers/accept
DELETE /offers/:id
POST /offers/rescind-bulk
GET /quests/me
POST /quests/email
POST /quests/x/start
POST /quests/x/verify-like
POST /quests/x/verify-repost
POST /quests/x/verify-reply
POST /quests/x/verify-follow
POST /quests/complete-all
GET /rewards/me
GET /rewards
GET /rewards/history
POST /rewards/:id/claim
Admin:
GET /admin/activity
GET /admin/analytics
GET /admin/blacklist
POST /admin/blacklist
DELETE /admin/blacklist/:id
GET /admin/collections
POST /admin/collections
PUT /admin/collections/order
PUT /admin/collections/:id
DELETE /admin/collections/:id
GET /admin/danger/operator-status
POST /admin/danger/promote-backup
GET /admin/rewards/rules
PUT /admin/rewards/rules
GET /admin/rewards/inventory
GET /admin/rewards/accounts
POST /admin/rewards/accounts/adjust
POST /admin/rewards/associate
PUT /admin/rewards/items/:id
POST /admin/rewards/items/:id/extract
GET /admin/rewards/ledger
GET /admin/settings
PUT /admin/settings
GET /admin/subcategories
POST /admin/subcategories
Internal (worker key):
POST /internal/loans/:id/default
POST /internal/loans/:id/reminder
Scope Details | |
|---|---|
| Repository | https://github.com/collafi_server→ |
| Commit | 8ec9653 |
| Whitepaper | https://hackenio.cc/hacken-methodologies→ |
| Requirements | N/A |
| Technical Requirements | N/A |
Scope Details
- Repository
- https://github.com/collafi_server→
- Commit
- 8ec9653
- Requirements
- N/A
- Technical Requirements
- N/A
Assets in Scope
Appendix 3. Additional Valuables
Frameworks and Methodologies
This security assessment was conducted in alignment with recognised penetration testing standards, methodologies and guidelines, including the NIST SP 800-115 – Technical Guide to Information Security Testing and Assessment →, the Penetration Testing Execution Standard (PTES) →, and the OWASP Testing Guide →. These assets provide a structured foundation for planning, executing, and documenting technical evaluations such as vulnerability assessments, exploitation activities, and security code reviews. Hacken’s internal penetration testing methodology extends these principles to Web2 and Web3 environments to ensure consistency, repeatability, and verifiable outcomes.