Canto - squeaky_cactus's results

A layer-1 EVM powered by free public infrastructure.

General Information

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

Canto

Findings Distribution

Researcher Performance

Rank: 16/23

Findings: 1

Award: $226.82

QA:
grade-a

🌟 Selected for report: 1

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: squeaky_cactus

Also found by: 3docSec, DevABDee, Rolezn, Shogoki, kaveyjoe, nadin, solsaver, vuquang23

Labels

bug
grade-a
high quality report
QA (Quality Assurance)
selected for report
sponsor confirmed
Q-06

Awards

226.8203 USDC - $226.82

External Links

QA Report

8 low issues and 2 non-critical found.

Low Risk

L-1 Params has both value and reference receivers

Params has two methods, one uses pointer and the other a value reciver. GoLang documentation recommends choosing either one or the other. (Arugments being consistency, readability and peformance) https://go.dev/doc/faq#methods_on_values_or_pointers

The Validate method is currently using a value receiever, this can be changed to a pointer without side affect (avoiding copying the struct on each call).

Reommended mitigation

Change the Params from value to reference.

x/onboarding/keeper/params.go:L89 - func (p Params) Validate() error { + func (p *Params) Validate() error {

L-2 Misleading method GoDoc calculateWithExactInput

GoDoc paramater of soldTokenDenom on swap:calculateWithExactInput is not a function parameter, however there is a boughtTokenDenom parameter (which would be an inversion of the GoDoc description).

Reommended mitigation
x/coinswap/keeper/swap.go:L33 - @param soldTokenDenom : received token's denom + @param boughtTokenDenom : demonination of token brought

L-3 Misleading method GoDoc GetPoolBalances

GoDoc mehod comment for pool:GetPoolBalances does not describe the method correctly (it may be a copy, paste & edit error from the proceeding method in the file).

Reommended mitigation
x/coinswap/keeper/pool.go:L69 - // GetPoolBalances return the liquidity pool by the specified anotherCoinDenom + // GetPoolBalances returns the coin balances of the liquidity pool by the specified address

L-4 Deprecated method on EmitEvent used

EmitEvent is deprecated in favor of EmitTypedEvent https://pkg.go.dev/github.com/cosmos/cosmos-sdk/types@v0.45.9#EventManager.EmitEvent

x/onboarding/kepper/ibc_callbacks.go:L97-105 ctx.EventManager().EmitEvent( sdk.NewEvent( coinswaptypes.EventTypeSwap, sdk.NewAttribute(coinswaptypes.AttributeValueAmount, swappedAmount.String()), sdk.NewAttribute(coinswaptypes.AttributeValueSender, recipient.String()), sdk.NewAttribute(coinswaptypes.AttributeValueRecipient, recipient.String()), sdk.NewAttribute(coinswaptypes.AttributeValueIsBuyOrder, strconv.FormatBool(true)), sdk.NewAttribute(coinswaptypes.AttributeValueTokenPair, coinswaptypes.GetTokenPairByDenom(transferredCoin.Denom, swapCoins.Denom)), ),
Reommended mitigation

Use EmitTypedEvent

L-5 Silent fail on no whitelisting

There is no logging on the early return condition of no whitelisted channels found for the detaination channel.

Logging this return condition would provide a data point for observability, suporting system monitoring an issue diagnosis.

Reommended mitigation
x/onboarding/kepper/ibc_callbacks.go:L56 +logger.Error("no whitelist channel found for %s",packet.DestinationChannel)

L-6 Silent fail on recipient account being a module

There is no logging on the early return condition when the recipient account is a module.

Logging this return condition would provide a data point for observability, suporting system monitoring an issue diagnosis.

Reommended mitigation
x/onboarding/kepper/ibc_callbacks.go:L71 +logger.Error("recipient account is a module %s",account.GetAddress())

L-7 Silent fail on missing ERC20 mapping

There is no logging on the early return condition when no ERC20 mapping is found for the denom.

Logging this return condition would provide a data point for observability, suporting system monitoring an issue diagnosis.

Reommended mitigation
x/onboarding/kepper/ibc_callbacks.go:L120 +logger.Error("no ERC20 mapping found for %s",transferredCoin.Denom)

L-8 Silent fail on trading pair disable

There is no logging on the early return condition when the trading pair is disabled.

Logging this return condition would provide a data point for observability, suporting system monitoring an issue diagnosis.

Reommended mitigation
x/onboarding/kepper/ibc_callbacks.go:L127 +logger.Error("disabled trading pair with id %s",pairID)

Non-Critical

NC-1 Dead GoDoc params for TradeExactInputForOutput

The GoDoc for swap:TradeExactInputForOutput contain two parameters are not in the method signature and there are no likely matching candidates, these lines should be deleted as they'll only serve to sow confusion.

swap.go L68-69 @param sender: address of the sender @param receipt: address of the receiver

Reommended mitigation
x/coinswap/keeper/swap.go:L68-69 -@param sender: address of the sender -@param receipt: address of the receiver

NC-2 Dead GoDoc params for TradeInputForExactOutput

The GoDoc for swap:TradeInputForExactOutput contain two parameters are not in the method signature and there are no likely matching candidates, these lines should be deleted as they'll only serve to sow confusion.

swap.go L68-69 @param sender: address of the sender @param receipt: address of the receiver

Reommended mitigation
x/coinswap/keeper/swap.go:L159-160 -@param sender : address of the sender -@param receipt : address of the receiver

#0 - c4-pre-sort

2023-06-24T19:54:36Z

JeffCX marked the issue as high quality report

#1 - tkkwon1998

2023-06-28T18:00:12Z

Really nice QA report

#2 - c4-sponsor

2023-06-28T18:00:29Z

tkkwon1998 marked the issue as sponsor confirmed

#3 - c4-judge

2023-07-02T00:50:34Z

0xean marked the issue as grade-a

#4 - c4-judge

2023-07-03T21:13:15Z

0xean marked the issue as selected for report

#5 - 0xean

2023-07-05T15:41:25Z

QA (Quality Assurance) Includes both Non-critical (code style, clarity, syntax, versioning, off-chain monitoring (events, etc) and Low risk (e.g. assets are not at risk: state handling, function incorrect as to spec, issues with comments). Excludes Gas optimizations, which are submitted and judged separately.

Based off the above from the c4 docs - I believe the following severities should be modified.

L-1 - NC L-4 - NC L-5 - NC L-6 - NC L-7 - NC L-8 - NC

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter