Closed howlbot-integration[bot] closed 2 months ago
Rewarding this one at 50% because, unlike other dupes, it does not report the same issue in repayDelinquentDebt
3docSec marked the issue as partial-50
Thank you for judging @3docSec ,
i submitted repayDelinquentDebt as a separate issue of this kind. kindly check issue 59. Well done
3docSec marked the issue as satisfactory
Lines of code
https://github.com/code-423n4/2024-08-wildcat/blob/fe746cc0fbedc4447a981a50e6ba4c95f98b9fe1/src/market/WildcatMarket.sol#L179-L184
Vulnerability details
Impact
When a borrower calls the
repayOutstandingDebt()
function, the expected behavior is that all outstanding debts should be repaid in full. However, due to a flaw in the implementation, specifically not processing expired or batched withdrawals after the debt repayment, the debt accumulates again after the repayment. This results in the system incurring more debt than expected, creating a financial discrepancy and making the repayment function ineffective as borrower will still have to pay more in a case where everyone has queued withdrawals.In essence, this issue allows debt to persist even after a full repayment is attempted, leading to inconsistent system behavior where the borrower continues to owe money even after settling their outstanding obligations.
Proof of Concept
The following two test setups demonstrate the bug in the
repayOutstandingDebt()
function:Test Case 1: Debt Repayment Without Updating
This test case fails because, 1 second after repayment, debt accumulates again. The reason is that pending withdrawals or accrued fees are not processed before the repayment, causing debt to resurface immediately.
Test Case 2: Debt Repayment with Market Update
In this case, the debt repayment works as expected because the
updateState()
function is called after repayment, ensuring that all expired and batched withdrawals are processed before the debt is recalculated. This test passes as the total debt does not accumulate again.Referencing another implementation in the code
Tools Used
Recommended Mitigation Steps
To resolve this issue, the system should process all pending withdrawals and update the market state after repaying the debt. This can be achieved by modifying the
repayOutstandingDebt()
function to include the state update immediately after repayment.Suggested Fix:
Assessed type
Error