function does not properly validate the buyBackAmount input
The vulnerability in the code between lines 43 to 78 is related to the lack of proper input validation and error handling. The function exitShortWallet allows a user to exit a short position by buying back a certain amount of ERC tokens. However, the function does not properly validate the buyBackAmount input. If the buyBackAmount is greater than the ercDebt or if it is zero, the function should revert with an error message. But instead, it only checks if buyBackAmount is greater than ercDebt or equal to zero, and if so, it reverts with an error message. This means that if buyBackAmount is less than zero, the function will not revert and will continue to execute, potentially leading to unexpected behavior or financial loss for the user. that could be exploited by an attacker to manipulate the contract's state and cause financial damage.
vscode
The issue can be resolved by adding an additional check to ensure that the buyBackAmount is greater than zero. This will prevent the function from executing if the buyBackAmount is less than or equal to zero. Here is the recommended code change:
Replace the existing check:
With the following:
This will ensure that the function reverts if the buyBackAmount is not within the expected range (greater than zero and less than or equal to ercDebt). This will prevent potential exploits and ensure the function behaves as expected.
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.