This repository has been archived by the owner on Dec 22, 2024. It is now read-only.
0x486776 - Improper implementation of the PositionMarginProcess.updatePositionFromBalanceMargin()
function.
#159
Labels
High
A valid High severity issue
Reward
A payout will be made for this issue
Sponsor Confirmed
The sponsor acknowledged this issue is valid
Will Fix
The sponsor confirmed this issue will be fixed
0x486776
High
Improper implementation of the
PositionMarginProcess.updatePositionFromBalanceMargin()
function.Summary
The updates to position values are not based on the current price of the
marginToken
.Vulnerability Detail
As shown in the code at
L314
andL318
, all calculations are based on percentages relative to the maximum values. They do not factor in the current price of themarginToken
. Consequently, even if the currentmarginToken
price is significantly lower than when the position was last updated, users can still update their position using the higher price.Impact
Users can update their positions'
initialMarginInUsdFromBalance
values using a price higher than the current price of themarginToken
.Code Snippet
https://github.com/sherlock-audit/2024-05-elfi-protocol/blob/main/elfi-perp-contracts/contracts/process/PositionMarginProcess.sol#L303-L338
Tool used
Manual Review
Recommendation
The
PositionMarginProcess.updatePositionFromBalanceMargin()
function should be based on the current price of themarginToken
.The text was updated successfully, but these errors were encountered: