Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Timelock and an Event to ClearingHouse.sol:setParams() #77

Closed
code423n4 opened this issue Feb 23, 2022 · 3 comments
Closed

Add a Timelock and an Event to ClearingHouse.sol:setParams() #77

code423n4 opened this issue Feb 23, 2022 · 3 comments
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

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2022-02-hubble/blob/main/contracts/ClearingHouse.sol#L344-L354

Vulnerability details

Impact

It is a good practice to give time for users to react and adjust to critical changes. A timelock provides more guarantees and reduces the level of trust required, thus decreasing risk for users. It also indicates that the project is legitimate.

Here, no timelock capabilities nor events are implemented on ClearingHouse.sol:setParams(), which I believe is a function that can impact some users enough to make them want to react / be notified ahead of time, as it changes these 4 parameters: tradeFee, liquidationPenalty, maintenanceMargin and minAllowableMargin

Proof of Concept

https://github.com/code-423n4/2022-02-hubble/blob/main/contracts/ClearingHouse.sol#L344-L354

File: ClearingHouse.sol
344:     function setParams(
345:         int _maintenanceMargin,
346:         int _minAllowableMargin,
347:         uint _tradeFee,
348:         uint _liquidationPenality
349:     ) external onlyGovernance {
350:         tradeFee = _tradeFee; 
351:         liquidationPenalty = _liquidationPenality;
352:         maintenanceMargin = _maintenanceMargin;
353:         minAllowableMargin = _minAllowableMargin;
354:     }

Recommended Mitigation Steps

Consider adding a timelock and an event to ClearingHouse.sol:setParams()
Additionally, I suggest adding an upperbound on tradeFee and liquidationPenalty, as too big of a possible value for those isn't good for trust.

@code423n4 code423n4 added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working labels Feb 23, 2022
code423n4 added a commit that referenced this issue Feb 23, 2022
@atvanguard
Copy link
Collaborator

Duplicate of #40

@atvanguard atvanguard marked this as a duplicate of #40 Feb 24, 2022
@atvanguard atvanguard added the duplicate This issue or pull request already exists label Feb 24, 2022
@moose-code
Copy link
Collaborator

Again gov can rug issue, but this is a very practical and useful suggestion 👍

@moose-code moose-code added QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Mar 10, 2022
@JeeberC4
Copy link

Grouping with warden's QA report #94

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

4 participants