In Gondi, when a new loan is issued, all the loan parameters are represented in the Loan struct. Only the hash value of this struct is stored on-chain. Therefore, when users want to interact with an existing loan, they need to input the entire Loan struct. This is necessary when users want to refinance, or borrowers want to repay the loan.
However, the protocolFee is not included in the Loan struct hash. As a result, users could input an arbitrary protocolFee value when they interact with an existing loan to avoid the protocol fee. For example, when a borrower repays the loan, the protocolFee is taken from the interest paid by the borrower. But since the loan.protocolFee could be input as 0, they can avoid this fee.
Observe the function used to hash the Loan struct and the Loan struct itself. It is clear that the protocolFee is not included in the Loan struct hash.
Lines of code
https://github.com/code-423n4/2024-04-gondi/blob/b9863d73c08fcdd2337dc80a8b5e0917e18b036c/src/lib/utils/Hash.sol#L136
Vulnerability details
Impact
In Gondi, when a new loan is issued, all the loan parameters are represented in the
Loan
struct. Only the hash value of this struct is stored on-chain. Therefore, when users want to interact with an existing loan, they need to input the entireLoan
struct. This is necessary when users want to refinance, or borrowers want to repay the loan.However, the
protocolFee
is not included in theLoan
struct hash. As a result, users could input an arbitraryprotocolFee
value when they interact with an existing loan to avoid the protocol fee. For example, when a borrower repays the loan, theprotocolFee
is taken from the interest paid by the borrower. But since theloan.protocolFee
could be input as0
, they can avoid this fee.Proof of Concept
Observe the function used to hash the
Loan
struct and theLoan
struct itself. It is clear that theprotocolFee
is not included in theLoan
struct hash.Tools Used
Manual Review
Recommended Mitigation Steps
Include
protocolFee
in theLoan
struct hash.Assessed type
Other