sherlock-audit / 2024-05-elfi-protocol-judging

0 stars 0 forks source link

jah - collateralUserCap is not properly checked when depositing #277

Closed sherlock-admin2 closed 1 week ago

sherlock-admin2 commented 2 weeks ago

jah

High

collateralUserCap is not properly checked when depositing

Summary

line 96 when checking collateralUserCap against the user balance it exclude the newly deposit amount

Vulnerability Detail

in AssetsProcess function deposit line 96 when checking the user deposited amount against the collateralUserCap it only check against the previous user deposit amount and it will not check the new one so since it exclude the newly deposit amount the user can bypass the collateralUserCap by depositing two times with collateralUserCap amount

Impact

breaks the contract policy

Code Snippet

https://github.com/sherlock-audit/2024-05-elfi-protocol/blob/main/elfi-perp-contracts/contracts/process/AssetsProcess.sol#L96

Tool used

Manual Review

Recommendation

update the account before checking

Duplicate of #262