You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Underfunding of Buyback and Fee Distributions Due to Fee-on-Transfer Tokens
Summary
The assumption that full feeToken balances transfer without deduction will cause a shortfall in distributed amounts for fee-on-transfer tokens, as the automatic transfer fee reduces the received amount when feeToken is forwarded to the aggregator or defiSafe.
Root Cause
The choice to rely on feeToken.balanceOf(address(this)) for full transfers without accounting for transfer fees is a mistake, as fee-on-transfer tokens will result in a smaller-than-expected amount reaching the destination.
Issue Location
The issue appears in the following lines within _buyBack and _feeDispersal:
SWAPPER_ROLE needs to call swap() or another function that invokes _feeDispersal or _buyBack using a fee-on-transfer token as feeToken.
feeToken must apply a transfer fee.
External pre-conditions
No response
Attack Path
SWAPPER_ROLE calls swap() or a related function with a fee-on-transfer token as feeToken.
In _feeDispersal or _buyBack, feeToken is forwarded to the aggregator or defiSafe.
Due to the transfer fee, the aggregator or defiSafe receives less than expected, potentially causing the buyback swap to fail or creating a shortfall in the distributed amount.
Impact
The protocol suffers from reduced reliability in buyback and fee distribution amounts, especially when handling fee-on-transfer tokens. This inconsistency can cause failed transactions in the aggregator or underpayment to defiSafe.
Using fee-on-transfer tokens without adjustments may lead to inconsistent buyback or fee distribution results due to transfer fees, affecting the stability and predictability of protocol operations.
PoC
Deploy a fee-on-transfer ERC20 token.
Call swap() with this token as feeToken.
Observe that the aggregator or defiSafe receives a reduced amount compared to the full feeToken balance.
Mitigation
Implement Balance Check Adjustments: Calculate the actual received amount after each transfer to account for fees.
Identify Fee-on-Transfer Tokens: Consider pre-detecting fee-on-transfer tokens and adjusting expected transfer values accordingly.
The text was updated successfully, but these errors were encountered:
sherlock-admin3
changed the title
Handsome Cotton Wolverine - Underfunding of Buyback and Fee Distributions Due to Fee-on-Transfer Tokens
AdamSzymanski - Underfunding of Buyback and Fee Distributions Due to Fee-on-Transfer Tokens
Nov 17, 2024
AdamSzymanski
Medium
Underfunding of Buyback and Fee Distributions Due to Fee-on-Transfer Tokens
Summary
The assumption that full
feeToken
balances transfer without deduction will cause a shortfall in distributed amounts for fee-on-transfer tokens, as the automatic transfer fee reduces the received amount whenfeeToken
is forwarded to the aggregator ordefiSafe
.Root Cause
The choice to rely on
feeToken.balanceOf(address(this))
for full transfers without accounting for transfer fees is a mistake, as fee-on-transfer tokens will result in a smaller-than-expected amount reaching the destination.Issue Location
The issue appears in the following lines within _buyBack and _feeDispersal:
Internal pre-conditions
SWAPPER_ROLE
needs to callswap()
or another function that invokes_feeDispersal
or_buyBack
using a fee-on-transfer token asfeeToken
.feeToken
must apply a transfer fee.External pre-conditions
No response
Attack Path
SWAPPER_ROLE
callsswap()
or a related function with a fee-on-transfer token asfeeToken
._feeDispersal
or_buyBack
,feeToken
is forwarded to the aggregator ordefiSafe
.defiSafe
receives less than expected, potentially causing the buyback swap to fail or creating a shortfall in the distributed amount.Impact
The protocol suffers from reduced reliability in buyback and fee distribution amounts, especially when handling fee-on-transfer tokens. This inconsistency can cause failed transactions in the aggregator or underpayment to
defiSafe
.Using fee-on-transfer tokens without adjustments may lead to inconsistent buyback or fee distribution results due to transfer fees, affecting the stability and predictability of protocol operations.
PoC
swap()
with this token asfeeToken
.defiSafe
receives a reduced amount compared to the fullfeeToken
balance.Mitigation
The text was updated successfully, but these errors were encountered: