Closed howlbot-integration[bot] closed 4 months ago
hansfriese marked the issue as unsatisfactory: Invalid
hansfriese marked the issue as not a duplicate
hansfriese changed the severity to 3 (High Risk)
Duplicate of #288. Will apply 50% partial credit as it didn't state the root cause.
hansfriese marked the issue as duplicate of #288
hansfriese marked the issue as partial-50
Lines of code
https://github.com/code-423n4/2024-06-size/blob/8850e25fb088898e9cf86f9be1c401ad155bea86/src/libraries/actions/SellCreditMarket.sol#L127-L202 https://github.com/code-423n4/2024-06-size/blob/8850e25fb088898e9cf86f9be1c401ad155bea86/src/libraries/AccountingLibrary.sol#L228-L249
Vulnerability details
Impact
Impact of Inconsistent Fee Deduction in
SellCreditMarket
The inconsistent fee deduction logic inSellCreditMarket.sol
can lead to unexpected behavior and potential financial disadvantages for users, particularly when they choose to sell credit withexactAmountIn = false
. src/libraries/actions/SellCreditMarket.sol#executeSellCreditMarketsrc/libraries/AccountingLibrary.sol#getCreditAmountIn
Proof of Concept
Scenario: Let's assume:
exactAmountIn = false
cashAmountOut = 100
ratePerTenor = 0
(for simplicity)swapFeePercent = 2
(2% fee)Transaction Flow:
executeSellCreditMarket
called:getCreditAmountIn
calculation:Funds Transfer:
Discrepancy: The user receives 100 units of
cashAmountOut
even though a 2% fee was applied. After deducting the fee, they should have received98
units.Proof: The bug stems from the fact that
getCreditAmountIn
calculates the fee but doesn't deduct it from thecashAmountOut
before it's used to determinecreditAmountIn
. WhenexactAmountIn
is false, the user receives a highercashAmountOut
than they should.Impact: This inconsistency creates a financial disadvantage for users who utilize the
exactAmountIn = false
option, as they effectively incur a hidden cost in the form of an inaccurately calculated fee deduction.Tools Used
Vs
Recommended Mitigation Steps
creditAmountIn
whenexactAmountIn
is false. This ensures that the user receives the specifiedcashAmountOut
after fees.cashAmountOut
before deducting fees whenexactAmountIn
is true. This makes the behavior consistent with theexactAmountIn = false
case.Assessed type
Error