-
Notifications
You must be signed in to change notification settings - Fork 4
xiaoming90 - depositAndAllocateForPartyB
is broken due to incorrect precision
#222
Comments
Escalate for 10 usdc |
You've created a valid escalation! To remove the escalation from consideration: Delete your comment. You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final. |
Escalate This should be valid medium, not high. There is no material loss of funds: funds are in the user account, just don't make it to the allocated balance, which can be easily fixed by allocating. The scenario described is quite unlikely: the partyB has to deposit just a few blocks before being liquidated which is not what users normally do. If such situation happens due to large price movement, then there is a higher probability that user is liquidated due to network congestion and being unable to deposit in time, rather than due to this bug. In all the other circumstances the user should have enough time to notice lack of allocated balance and react appropriately. Since loss of funds is possible but not very likely, this should be medium. |
You've created a valid escalation! To remove the escalation from consideration: Delete your comment. You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final. |
Escalate The feature ( Liquidations frequently occur in the real world, particularly within large protocols (e.g. Compound, AAVE). Assuming that one of their deposit functions has a bug where deposited assets fail to increase the account's collateral level appropriately, it is certain that their users and external protocols that integrate with them will be unfairly liquidated, suffering a loss. The same applies here. Thus, it should be considered of High severity. |
You've created a valid escalation! To remove the escalation from consideration: Delete your comment. You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final. |
Agree with senior watson, the severity is indeed high because of the broken accounting will address securitygrid's escalation seperately |
Escalate The bug does not cause a loss of funds, but fails to allocate funds. The scenario described by Lead watson in addition of being highly unlikely as a setup, assumes a user mistake as the trigger:
Severity should be low |
You've created a valid escalation! To remove the escalation from consideration: Delete your comment. You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final. |
Fixed code PR link: |
Result: While I can understand the @panprog's argument to make this a medium, I do not think this is a strong enough reason to downgrade this issue.
In addition to the points mentioned above agree with @xiaoming9090's points here:
Also regarding @securitygrid's escalation, although agree with the points, the issues mentioned will still be considered duplicates because of the duplication rules |
Escalations have been resolved successfully! Escalation status:
|
xiaoming90
high
depositAndAllocateForPartyB
is broken due to incorrect precisionSummary
Due to incorrect precision, any users or external protocols utilizing the
depositAndAllocateForPartyB
to allocate 1000 USDC will end up only having 0.000000001 USDC allocated to their account. This might potentially lead to unexpected loss of funds due to the broken functionality if they rely on the accuracy of the function outcome to perform certain actions that deal with funds/assets.Vulnerability Detail
The input
amount
of thedepositForPartyB
function must be in native precision (e.g. USDC should be 6 decimals) as the function will automatically scale the amount to 18 precision in Lines 114-115 below.https://github.com/sherlock-audit/2023-06-symmetrical/blob/main/symmio-core/contracts/facets/Account/AccountFacetImpl.sol#L108
On the other hand, the input
amount
ofallocateForPartyB
function must be in 18 decimals precision. Within the protocol, it uses 18 decimals for internal accounting.https://github.com/sherlock-audit/2023-06-symmetrical/blob/main/symmio-core/contracts/facets/Account/AccountFacetImpl.sol#L119
The
depositAndAllocateForPartyB
function allows the users to deposit and allocate to their accounts within a single transaction. Within the function, it calls thedepositForPartyB
function followed by theallocateForPartyB
function. The function passes the sameamount
into both thedepositForPartyB
andallocateForPartyB
functions. However, the problem is that one acceptsamount
in native precision (e.g. 6 decimals) while the other acceptsamount
in scaled decimals (e.g. 18 decimals).Assume that Alice calls the
depositAndAllocateForPartyB
function and intends to deposit and allocate 1000 USDC. Thus, she set theamount
of thedepositAndAllocateForPartyB
function to1000e6
as the precision of USDC is6
.The
depositForPartyB
function at Line 78 will work as intended because it will automatically be scaled up to internal accounting precision (18 decimals) within the function, and 1000 USDC will be deposited to her account.The
allocateForPartyB
at Line 79 will not work as intended. The function expects theamount
to be in internal accounting precision (18 decimals), but anamount
in native precision (6 decimals for USDC) is passed in. As a result, only 0.000000001 USDC will be allocated to her account.https://github.com/sherlock-audit/2023-06-symmetrical/blob/main/symmio-core/contracts/facets/Account/AccountFacet.sol#L74
Impact
Any users or external protocols utilizing the
depositAndAllocateForPartyB
to allocate 1000 USDC will end up only having 0.000000001 USDC allocated to their account, which might potentially lead to unexpected loss of funds due to the broken functionality if they rely on the accuracy of the outcome to perform certain actions dealing with funds/assets.For instance, Bob's account is close to being liquidated. Thus, he might call the
depositAndAllocateForPartyB
function in an attempt to increase its allocated balance and improve its account health level to avoid being liquidated. However, thedepositAndAllocateForPartyB
is not working as expected, and its allocated balance only increased by a very small amount (e.g. 0.000000001 USDC in our example). Bob believed that his account was healthy, but in reality, his account was still in danger as it only increased by 0.000000001 USDC. In the next one or two blocks, the price swung, and Bob's account was liquidated.Code Snippet
https://github.com/sherlock-audit/2023-06-symmetrical/blob/main/symmio-core/contracts/facets/Account/AccountFacet.sol#L74
Tool used
Manual Review
Recommendation
Scale the
amount
to internal accounting precision (18 decimals) before passing it to theallocateForPartyB
function.The text was updated successfully, but these errors were encountered: