Canto - DevABDee'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: 17/23

Findings: 1

Award: $174.48

QA:
grade-a

🌟 Selected for report: 0

🚀 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)
sponsor confirmed
Q-05

Awards

174.4771 USDC - $174.48

External Links

Low Findings:

L1: Pool.CreatePool() doesn't checks if the pool already exists

The pool.CreatePool() function, as currently implemented, does not perform a check to see if the pool already exists. This means that multiple instances of the same pool can be created, potentially leading to duplication or inconsistencies within the system. Add a check for that.

func (k Keeper) CreatePool(ctx sdk.Context, counterpartyDenom string) types.Pool {
	poolID := types.GetPoolId(counterpartyDenom)

	// Check if the pool already exists
	if k.poolExists(ctx, poolID) {
		panic("Pool already exists") // or return an error, depending on your use case
	}

	sequence := k.getSequence(ctx)
	lptDenom := types.GetLptDenom(sequence)
	pool := &types.Pool{
		Id:                poolID,
		StandardDenom:     k.GetStandardDenom(ctx),
		CounterpartyDenom: counterpartyDenom,
		EscrowAddress:     types.GetReservePoolAddr(lptDenom).String(),
		LptDenom:          lptDenom,
	}
	k.setSequence(ctx, sequence+1)
	k.setPool(ctx, pool)
	return *pool
}

func (k Keeper) poolExists(ctx sdk.Context, poolID string) bool {
	// Implement the logic to check if the pool exists in the state or database
	// Return true if the pool exists, false otherwise
	// You need to customize this implementation based on your specific requirements
	_, found := k.getPool(ctx, poolID)
	return found
}

Note, the solution code is generated by ChatGPT :D

L2: Swap functions are missing transaction expiration checks

The swap.TradeInputForExactOutput() and swap.TradeExactInputForOutput() functions are part of a swap mechanism that allows users to exchange one type of token for another based on specific input and output requirements. However, it is important to note that these functions currently lack transaction expiration checks, which can introduce potential vulnerabilities.

To enhance the security and robustness of the swap mechanism, it is recommended to incorporate transaction expiration checks into the swap.TradeInputForExactOutput() and swap.TradeExactInputForOutput() functions. By doing so, the system can ensure that trades are executed within a valid timeframe, reducing the risk of potential exploits or discrepancies in token exchanges.

Non-Critical Findings:

NC-1: @param details/comments missing

func [OnRecvPacket()](https://github.com/code-423n4/2023-06-canto/blob/a4ff2fd2e67e77e36528fad99f9d88149a5e8532/Canto/x/onboarding/keeper/ibc_callbacks.go#L28) and some other functions as well are missing @param details/comments. Add that.

NC-2: package comments missing

The codebase lacks package comments, which are comments specifically written at the package level to provide an overview and description of the package's functionality and purpose. Package comments serve as a documentation header for the entire package and provide important context for developers and users of the package.

Including package comments is considered a good practice

NC-3: Improper function ordering

Define private functions first, followed by public functions. It's a common practice in go. That will increase the readability & audibility of the codebase.

NC-4: Line Limit Exceeds

Some code lines exceed the line limit (80). PoC: https://github.com/code-423n4/2023-06-canto/blob/a4ff2fd2e67e77e36528fad99f9d88149a5e8532/Canto/x/coinswap/keeper/swap.go#L146

NC-5: Explicitly set variables

It's good practice to set variables explicitly for better readability & audibility. Change from this:

var found bool

to this:

var found bool = false

#0 - c4-pre-sort

2023-06-24T19:54:12Z

JeffCX marked the issue as high quality report

#1 - c4-sponsor

2023-06-28T18:07:52Z

tkkwon1998 marked the issue as sponsor confirmed

#2 - c4-judge

2023-07-02T00:50:32Z

0xean marked the issue as grade-a

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