Platform: Code4rena
Start Date: 20/06/2023
Pot Size: $36,500 USDC
Total HM: 2
Participants: 23
Period: 3 days
Judge: 0xean
Id: 252
League: ETH
Rank: 4/23
Findings: 1
Award: $3,388.28
🌟 Selected for report: 0
🚀 Solo Findings: 0
3388.2784 USDC - $3,388.28
https://github.com/code-423n4/2023-06-canto/blob/main/Canto/x/coinswap/keeper/swap.go#L210 https://github.com/code-423n4/2023-06-canto/blob/main/Canto/x/coinswap/types/params.go#L31-L35
It is stated in the README
that some spend limit are configured for the swaps.
This is a security precaution to avoid spending too much tokens for the default 4 CANTO
tokens in order to onboard the users if their balance is less than 4 tokens.
As a default, this spend limit should be 10$ for all tokens.
The inital tokens than can be bridged on Canto are = 19$)USDC
, USDT
, and ETH
, and so their respective spending limit should be 10
, 10
, 0.01
(
In the current implementation of the code, this spend limit is fetched from calling the GetMaximumSwapAmount
function at the time of swaps.
The default swap limit is set in the params.go
and as we can see, it's correct for the USDC
and USDT
(according to their 6 decimals in all EVM chains), but not for ETH
.
Indeed, the DefaultMaxSwapAmount
for ETH
is set initially at 1e17, which equals 0.1 ETH.
Intially, the expected value should have been about 10$ for each asset, but here it's about 190$, which is far more than expected (20x).
The impact is that if in the future, the CANTO
price goes up and that some ETH
are bridged to onboard a new user, then it may swap much more than the expected 0.01
ETH, and may swap up to 0.1
ETH before aborting the swap operation.
Manual inspection
Update the DefaultMaxSwapAmount
to have a default for ETH
at 0.01 ETH
DefaultMaxSwapAmount = sdk.NewCoins( sdk.NewCoin(UsdcIBCDenom, sdk.NewIntWithDecimal(10, 6)), sdk.NewCoin(UsdtIBCDenom, sdk.NewIntWithDecimal(10, 6)), - sdk.NewCoin(EthIBCDenom, sdk.NewIntWithDecimal(1, 17)), + sdk.NewCoin(EthIBCDenom, sdk.NewIntWithDecimal(1, 16)), )
Decimal
#0 - c4-pre-sort
2023-06-24T12:21:26Z
JeffCX marked the issue as duplicate of #8
#1 - c4-judge
2023-07-03T20:49:16Z
0xean marked the issue as satisfactory
#2 - c4-judge
2023-07-03T20:50:22Z
0xean changed the severity to 3 (High Risk)