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
Description: Description
The previewRate() function in Router.sol is meant to simulate the execute() operation and returns the expected preview rate value. It uses a TokenBalance[] array to track token balance changes during the preview operations.
A critical issue exists where the function will always revert if the first command is a transfer operation (TRANSFER command) that attempts to decrease a token balance. This occurs because:
The TokenBalance[] array is initially empty
When processing a transfer command, _decreasePreviewTokenValue() is called
_decreasePreviewTokenValue() attempts to find the token in the empty balance array
Since the token isn't found (as no balances have been added yet), it reverts with BalanceUnderflow
This prevents any command sequence starting with a transfer from being previewed, which is a common legitimate use case.
Attack Scenario\
User wants to preview a complex swap that starts with transferring tokens from the router contract to their own address/ some other address.
The command sequence starts with TRANSFER followed by other operations
When calling previewRate(), the function will always revert on the first command
This prevents users from getting rate previews for many legitimate transaction sequences
Github username: --
Twitter username: --
Submission hash (on-chain): 0x62fb4103a30989fdc9fe46119a83c44345dba191f468db8b5291a3c091ac52b3
Severity: high
Description:
Description
The
previewRate()
function in Router.sol is meant to simulate theexecute()
operation and returns the expected preview rate value. It uses aTokenBalance[]
array to track token balance changes during the preview operations.A critical issue exists where the function will always revert if the first command is a transfer operation (
TRANSFER
command) that attempts to decrease a token balance. This occurs because:TokenBalance[]
array is initially empty_decreasePreviewTokenValue()
is called_decreasePreviewTokenValue()
attempts to find the token in the empty balance arrayBalanceUnderflow
This prevents any command sequence starting with a transfer from being previewed, which is a common legitimate use case.
Attack Scenario\
TRANSFER
followed by other operationspreviewRate()
, the function will always revert on the first commandAttachments
Fix is non-trivial. There needs to be a way to track negative balances to ensure that final balances are settled.
The text was updated successfully, but these errors were encountered: