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

MarginAccount: Computation of margin may be prone to errors from fee on transfer tokens #62

Closed
code423n4 opened this issue Feb 22, 2022 · 2 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/MarginAccount.sol#L157

Vulnerability details

Impact

USDT is the most widely used stablecoin so it is reasonable to assume that (like other lending platforms) USDT will be used as a possible collateral option. This may be problematic for Hubble down the road if Tether chooses to turn on their fee on transfer (line 126). This will result in the wrong amount of margin added when addMarginFor() is called.

Recommended Mitigation Steps

  • Track the balance before and after the token transfer then calculate the diff. This delta represents the actual amount transferred.
  • Be mindful of the tokens that are added as collateral e.g. avoid rebasing tokens
@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 22, 2022
code423n4 added a commit that referenced this issue Feb 22, 2022
@atvanguard
Copy link
Collaborator

Duplicate of #80

@atvanguard atvanguard marked this as a duplicate of #80 Feb 24, 2022
@atvanguard atvanguard added the duplicate This issue or pull request already exists label Feb 24, 2022
@JasoonS JasoonS 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 6, 2022
@JeeberC4
Copy link

Grouping with warden's QA report #63

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