Consistently check account balance before and after transfers for Fee-On-Transfer discrepencies #80
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
sponsor acknowledged
Technically the issue is correct, but we're not going to resolve it for XYZ reasons
Lines of code
https://github.com/code-423n4/2022-02-hubble/blob/main/contracts/MarginAccount.sol#L149-L159
https://github.com/code-423n4/2022-02-hubble/blob/main/contracts/MarginAccount.sol#L548-L562
https://github.com/code-423n4/2022-02-hubble/blob/main/contracts/MarginAccount.sol#L611-L613
Vulnerability details
Impact
Wrong increase on margin amount.
Wrong amount emitted.
Proof of Concept
In the public function
addMarginFor()
, an arbitrary ERC20 token can be passed as an argument:Even if the whitelisted Collateral coin is known by the Governance: the received amount should be calculated every time to take into consideration a possible present or future transfer-on-fee or deflation.
Also, it's a good practice for the future of the solution.
Tools Used
VS Code
Recommended Mitigation Steps
Check the balance before and after the transfer to take into account the Fees-On-Transfer.
As an example:
The text was updated successfully, but these errors were encountered: