The fixUser function in the MErc20DelegateFixer contract does not incorporate checks to prevent duplicate invocations for the same user, potentially leading to inconsistent financial states within the platform. This oversight could result in the artificial inflation of the badDebt variable without an actual increase in the user's borrow balance, inaccurately reflecting the platform's financial health.
The fixUser function is designed to zero out a user's borrow balance and transfer their collateral to a liquidator, subsequently increasing the badDebt counter by the user's principal amount. However, the function lacks a mechanism to prevent repeated executions for the same user when their borrow balance remains unchanged (i.e., already zeroed out by a previous call). This could allow for multiple increases in badDebt without actual debt being liquidated, if fixUser is called more than once for the same user under the same conditions.
Here's an example scenario to illustrate the vulnerability:
Alice is a user on the lending platform, and she has borrowed 100 tokens from the platform. Due to market conditions, Alice's collateral has been liquidated, and the fixUser function is called to handle her case.
The fixUser function correctly zeroes out Alice's borrow balance and transfers her collateral to the liquidator. It also increases the badDebt counter by 100 tokens, reflecting Alice's principal amount.
However, due to the lack of a duplicate prevention mechanism in the fixUser function, it is possible for the function to be called again for Alice, even though her borrow balance is already zero.
If fixUser is called a second time for Alice, it will execute its logic again, even though Alice's borrow balance is already zeroed out. This will result in another increase of 100 tokens to the badDebt counter, despite no new debt being liquidated.
The scenario can be repeated multiple times, leading to a significant inflation of the badDebt metric without an actual increase in the platform's debt. This could provide an inaccurate representation of the platform's financial health and potentially be exploited to manipulate financial metrics.
For example, if fixUser is called 10 times for Alice, the badDebt counter would increase by 1000 tokens, even though Alice's actual debt was only 100 tokens.
Repeated calls to fixUser for the same user without changes in the user's borrow balance could:
Inflate the badDebt metric, undermining the accuracy of the platform's financial reporting.
Potentially exploit the system by artificially manipulating financial metrics.
Affect the platform's risk assessments and financial stability.
Manual Review, python
Introduce a check at the beginning of the fixUser function to ensure that it only proceeds if the user's current borrow balance (accountBorrows[user].principal) is non-zero. This prevents the function from executing its logic (and thus affecting the badDebt counter) if the user has already been fixed and their borrow balance is zero.
```solidity
require(accountBorrows[user].principal != 0, "user already fixed");
```
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.