Negative value of liquidationFee will result to financial losses
Summary
There are no explicit checks to prevent the liquidationFee from having a negative value
Vulnerability Detail
If the liquidationFee is negative (less than zero), when calling transferOutVusd with this negative value, it will effectively result in adding VUSD tokens to the marginAccount from the to address, which shouldn't happen during liquidation. It may allow traders to exploit the liquidation process and receive funds instead of losing them.
Impact
It allows traders to drain funds from the contract, manipulate their liquidation process, or even exploit the liquidation mechanism to their advantage
seerether
high
Negative value of liquidationFee will result to financial losses
Summary
There are no explicit checks to prevent the liquidationFee from having a negative value
Vulnerability Detail
If the liquidationFee is negative (less than zero), when calling transferOutVusd with this negative value, it will effectively result in adding VUSD tokens to the marginAccount from the to address, which shouldn't happen during liquidation. It may allow traders to exploit the liquidation process and receive funds instead of losing them.
Impact
It allows traders to drain funds from the contract, manipulate their liquidation process, or even exploit the liquidation mechanism to their advantage
Code Snippet
https://github.com/sherlock-audit/2023-04-hubble-exchange/blob/main/hubble-protocol/contracts/ClearingHouse.sol#L216-L229
Tool used
Manual Review
Recommendation
A check should be added in the _liquidateSingleAmm function to ensure that the liquidationFee is positive before calling the transferOutVusd function. This can be done by adding a condition to check if liquidationFee is less than zero and reverting the transaction if it is https://github.com/seerether/Hubble/blob/0bec1b278bce0a730fef6127984134fed5ab47da/Hubblemitigate1#L7