Contract fails to deliver promised returns, but doesn't lose value
Protocol insolvency
Griefing (e.g. no profit motive for an attacker, but damage to the users or the protocol)
Description
Brief/Intro
The createSettlement function in the Settlement contract lacks crucial array length validation between the _loanIds and _loans parameters. This oversight allows partial processing of authorized settlements where only a subset of operator-signed loans are processed, creating a critical discrepancy between authorized and executed operations.
Vulnerability Details
The vulnerability exists in the createSettlement function at lines 113-114 and 139-147 in src/Settlement.sol:
The logical flaw stems from the asymmetric treatment of two related arrays:
Signature Generation: The _getSettlementHash includes both complete arrays in the signature calculation
Processing Logic: The loop boundary depends solely on _loanIds.length while accessing both arrays with identical indices
Missing Validation: No enforcement mechanism ensures array length equality before processing
This creates two possible scenarios:
Scenario A: _loans.length < _loanIds.length
Triggers array out-of-bounds access when i >= _loans.length
Results in automatic transaction reversion due to Solidity bounds checking
Scenario B: _loans.length > _loanIds.length
Processes only the first _loanIds.length entries from both arrays
Remaining _loans entries are silently ignored despite being part of the operator's signature
Creates discrepancy between authorized data and executed operations
Impact Details
When _loans.length > _loanIds.length, only a subset of intended loans undergo settlement while the operator's signature authorizes the complete set. This creates several issues:
Partial Execution: The operator's signature authorizes a complete set of loans, but only a subset gets processed
Settlement Confusion: Users and operators may believe all loans were settled when only some were