tradeFee and liquidationPenalty can be set to any value > 0 #84
Labels
bug
Something isn't working
duplicate
This issue or pull request already exists
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
Lines of code
https://github.com/code-423n4/2022-02-hubble/blob/ed1d885d5dbc2eae24e43c3ecbf291a0f5a52765/contracts/ClearingHouse.sol#L344
Vulnerability details
Impact
If
tradeFee or liquidationPenalty
is set above PRECISION(1e6), it will charge more than entire trade amount as fee which will lead to negative margin of the user.If
tradeFee+liquidationPenalty
is set abovemaintenanceMargin
, the user will have negative margin after liquidation.If
tradeFee
is set abovemaintenanceMargin
, it is possible for the user to have negative margin after closing position.Proof of Concept
https://github.com/code-423n4/2022-02-hubble/blob/ed1d885d5dbc2eae24e43c3ecbf291a0f5a52765/contracts/ClearingHouse.sol#L344
Recommended Mitigation Steps
To make sure the protocol remains functional, hard rules should be set to avoid the above situation in
setParams
. To reduce centralization risk, it is also advised a max fee being hardcoded to the contract (e.g. 10%).The text was updated successfully, but these errors were encountered: