Closed sherlock-admin closed 9 months ago
1 comment(s) were left on this issue during the judging contest.
takarez commented:
invalid
Invalid, agree with sponsors comments:
- Invalid, Not in favour user or protocol (risk manager can just set maxExposure to 1 less)
- Unlike with conversions shares assets, this cannot be abused by looping
deth
medium
AbstractDerivedAM.sol#processIndirectDeposit() - Incorrect rounding direction will favor the user
Summary
Incorrect rounding direction will favor the user
Vulnerability Detail
When calculating the exposure of an asset when depositing, we use
processIndirectDeposit
usdExposureUpperAssetToAsset
is used in the calculation and mutation oflastUsdExposureProtocol
usdExposureAsset
is then added tolastUsdExposureProtocol
and the valueusdExposureProtocol
is compared withmaxUsdExposure
.The issue here is that when we calculate
usdExposureUpperAssetToAsset
we round down, after which we compare a value that containsusdExposureUpperAssetToAsset
tomaxUsdExposureProtocol
which acts as an invariant, the idea is to disallow depositing of assets as to not over expose the protocol.Because of the rounding direction, there will be less exposure recorded on a deposit, which favors the users of the protocol.
The protocol team state.
Considering
maxUsdExposureProtocol
is a protocol value used in an invariant I consider this a Medium severity issue.Note that
processIndirectWithdrawal
rounds down correctly, as when we withdraw we want to remove less exposure, thus favoring the protocol, while when depositing we should round up, as it will add more exposure, which favors the protocol.Impact
Incorrect rounding will favor the users, instead of the protocol, which will allow for more exposure by the users.
Code Snippet
https://github.com/sherlock-audit/2023-12-arcadia/blob/de7289bebb3729505a2462aa044b3960d8926d78/accounts-v2/src/asset-modules/abstracts/AbstractDerivedAM.sol#L294
Tool used
Manual Review
Recommendation
Use
mulDivUp
instead ofmulDivDown
Duplicate of #1