Introduction
We express our gratitude to the Kopi team for the collaborative engagement that enabled the execution of this Blockchain Protocol Security Assessment.
Kopi is a Cosmos-SDK-based protocol featuring a flexible TokenFactory module for on-chain custom asset issuance, metadata management, and seamless liquidity integration.
Document | |
|---|---|
| Name | Blockchain Protocol Review and Security Analysis Report for Kopi |
| Audited By | Mike Mu |
| Approved By | Nino Lipartiia, Tanuj Soni |
| Website | https://kopi.money/→ |
| Changelog | 10/07/2025 - Preliminary Report |
| Changelog | 24/07/2025 - Final Report |
| Platform | Cosmos SDK |
| Language | Golang |
| Tags | L1, Cosmos SDK |
| Methodology | https://hackenio.cc/blockchain_methodology→ |
Document
- Name
- Blockchain Protocol Review and Security Analysis Report for Kopi
- Audited By
- Mike Mu
- Approved By
- Nino Lipartiia, Tanuj Soni
- Website
- https://kopi.money/→
- Changelog
- 10/07/2025 - Preliminary Report
- Changelog
- 24/07/2025 - Final Report
- Platform
- Cosmos SDK
- Language
- Golang
- Tags
- L1, Cosmos SDK
- Methodology
- https://hackenio.cc/blockchain_methodology→
Review Scope | |
|---|---|
| Repository | https://github.com/kopi-money/kopi/tree/v22-rc6/x/tokenfactory→ |
| Commit | 0a1232fc4bed69610dc350eb1881f6237c892863 |
Review Scope
- Commit
- 0a1232fc4bed69610dc350eb1881f6237c892863
Audit Summary
The system users should acknowledge all the risks summed up in the risks section of the report
Documentation quality
Provides clear guidance for end-users; however, additional detail for developers would enhance usability.
Presents strong conceptual framing, though it would benefit from the inclusion of formal specifications.
Follows a logical structure, but lacks a high-level architectural overview.
Aligned with the current codebase version, yet includes limited inline documentation.
Features readable and well-written prose, though offering more practical examples would further improve clarity.
Code quality
Effectively reuses Cosmos-SDK patterns, with some opportunities to reduce duplication. Keeper methods, message handlers, and collection wiring align well with standard SDK idioms, offering immediate familiarity for Cosmos-SDK developers.
Employs well-structured cache prefixes. The use of typed
collections.Prefixconstants withcache.Newcreates clear and strongly-typed storage namespaces.Demonstrates strong typing and well-defined domain models.
The code is generally readable and idiomatic Go, though a few minor naming inconsistencies remain.
Maintains a lean dependency footprint. While schema setup can be verbose, it is clear and explicit.
Inline documentation is limited but partially offset by clear, self-documenting code structure.
Architecture quality
Modular, Cosmos-SDK–native design. Tokenfactory plugs cleanly into the Cosmos-SDK keeper/model framework, inheriting its well-understood module lifecycle, upgrade path, and governance hooks.
In-chain performance & scalability. All Tokenfactory logic runs on the existing Tendermint-powered chain, so it benefits from Cosmos’s low-latency, high-throughput consensus without adding extra inter-module hops.
Clear separation of concerns. State management (via
collections), business logic (inkeepermethods), and parameter tuning (via on-chainParams) are neatly layered, making each component easier to reason about and test.Limited observability & metrics. There’s no built-in telemetry for critical flows (e.g. mint/burn rates, rate-limit breaches), so you’ll need external instrumentation to monitor performance and anomalies.
Test coverage
Code coverage of the project is ~30% and mutation score of ~60%
Branch coverage is primarily focused on happy paths; error-handling branches (e.g.,
if err != nilor negative conditions) are generally not exercised in tests.Critical edge cases and negative scenarios are underrepresented - many
Err...conditions in keeper logic and message validation remain untested.Potential issues with cache and prefix usage are not currently covered by tests.
System Overview
The Tokenfactory is the on-chain minting and metadata subsystem in the Kopi protocol, built as a Cosmos-SDK module. It lets users spin up fully on-chain custom tokens, control their lifecycle (minting, metadata updates, admin changes), and wire them into decentralized liquidity pools. All state is managed via the module’s keeper and persisted using the Cosmos-SDK collections framework.
Core Responsibilities
Token Issuance Supply Control
Users (the “creator”/admin) call
MsgCreateDenomto mint an initial supply of a new “factory” token.Post-creation, they can mint or burn further units (if allowed) via module messages.
Metadata Management
Through MsgUpdateDescription,
MsgUpdateWebsite, andMsgUpdateIconHash, admins can tweak human-readable fields (description text, website URL, image hash), subject to on-chain rate limits.
Permissioned Admin Role
Each token has an on-chain Admin address. Ownership can be transferred with
MsgChangeAdmin, guaranteeing only the current admin may update supply or metadata.
Custom Liquidity Pools
Optionally at creation (or any time later), a new factory token can be paired against the protocol’s base kCoin in a Constant Product pool (x/tokenfactory pools), enabling trading via the DEX keeper.
Fee Reserve Mechanics
Every trade routed through a Tokenfactory pool splits fees between the liquidity pool and the protocol reserve, according to on-chain parameters.
Major Components
Keeper
Orchestrates state reads/writes via typed
collections.Prefixcaches (denoms, pools, offers, vestings, etc.)Implements handlers for all tokenfactory messages (create, update, trade, admin change).
Types Messages
FactoryDenomstruct: on-chain record of token supply, admin, metadata, and timing-windows.LiquidityPoolstruct: reserves of kCoin vs. factory token, fee parameters, reserve-fee share.Proto messages (
MsgCreateDenom,MsgSell/MsgBuy, etc.) withValidateBasiclogic.
Parameters from onchain Params
MaxDenomNameLength,MaxDescriptionLength,MaxWebsiteLength: enforce metadata size limits.ChangeSecondsDescription,ChangeSecondsWebsite,ChangeSecondsImage: rate-limit how often metadata can be updated.ReserveFeeShare: fraction of trade fees that goes to the protocol reserve vs. the pool.
Auxiliary Modules
BankKeeper: mints/burns coins and moves them between accounts and module accounts.DexKeeper: if using the DEX abstraction for cross-token trades.Reservemodule: for storing protocol revenues.
Risks
While TokenFactory’s integration with the Cosmos-SDK offers a solid foundation, certain design choices introduce operational risks. Admin-controlled minting and metadata updates concentrate power in a single address, which could impact trust and governance if misused. Additionally, unrestricted pool creation may lead to liquidity fragmentation, reducing market depth and increasing slippage for users.
Findings
Code ― | Title | Status | Severity | |
|---|---|---|---|---|
| F-2025-1121 | Erroneous Categories.Equal Method Implementation | fixed | High | |
| F-2025-1137 | Inappropriate Prefix Usage in Cache Initialization | fixed | Medium | |
| F-2025-1153 | Missing Request Parameter Null Checks in Query Functions | fixed | Low | |
| F-2025-1151 | CLI Command Parameter Name Mismatch in AutoCLI Configuration | fixed | Low | |
| F-2025-1137 | Missing State Validation in DisableMinting Operation | fixed | Low | |
| F-2025-1122 | Error Handling and Parsing Issues | fixed | Low | |
| F-2025-1122 | Incorrect Timestamp Field Usage in UpdateWebsite Method | fixed | Low | |
| F-2025-1121 | Insufficient or Missing Input Validation | fixed | Low | |
| F-2025-1157 | Inconsistent Module Account Naming Convention | fixed | Observation | |
| F-2025-1157 | Error Code and Naming Issues in Error Definitions | fixed | Observation |
Appendix 1. Severity Definitions
Severity | Description |
|---|---|
Critical | Vulnerabilities that can lead to a complete breakdown of the blockchain network's security, privacy, integrity, or availability fall under this category. They can disrupt the consensus mechanism, enabling a malicious entity to take control of the majority of nodes or facilitate 51% attacks. In addition, issues that could lead to widespread crashing of nodes, leading to a complete breakdown or significant halt of the network, are also considered critical along with issues that can lead to a massive theft of assets. Immediate attention and mitigation are required. |
High | High severity vulnerabilities are those that do not immediately risk the complete security or integrity of the network but can cause substantial harm. These are issues that could cause the crashing of several nodes, leading to temporary disruption of the network, or could manipulate the consensus mechanism to a certain extent, but not enough to execute a 51% attack. Partial breaches of privacy, unauthorized but limited access to sensitive information, and affecting the reliable execution of smart contracts also fall under this category. |
Medium | Medium severity vulnerabilities could negatively affect the blockchain protocol but are usually not capable of causing catastrophic damage. These could include vulnerabilities that allow minor breaches of user privacy, can slow down transaction processing, or can lead to relatively small financial losses. It may be possible to exploit these vulnerabilities under specific circumstances, or they may require a high level of access to exploit effectively. |
Low | Low severity vulnerabilities are minor flaws in the blockchain protocol that might not have a direct impact on security but could cause minor inefficiencies in transaction processing or slight delays in block propagation. They might include vulnerabilities that allow attackers to cause nuisance-level disruptions or are only exploitable under extremely rare and specific conditions. These vulnerabilities should be corrected but do not represent an immediate threat to the system. |
Severity
- Critical
Description
- Vulnerabilities that can lead to a complete breakdown of the blockchain network's security, privacy, integrity, or availability fall under this category. They can disrupt the consensus mechanism, enabling a malicious entity to take control of the majority of nodes or facilitate 51% attacks. In addition, issues that could lead to widespread crashing of nodes, leading to a complete breakdown or significant halt of the network, are also considered critical along with issues that can lead to a massive theft of assets. Immediate attention and mitigation are required.
Severity
- High
Description
- High severity vulnerabilities are those that do not immediately risk the complete security or integrity of the network but can cause substantial harm. These are issues that could cause the crashing of several nodes, leading to temporary disruption of the network, or could manipulate the consensus mechanism to a certain extent, but not enough to execute a 51% attack. Partial breaches of privacy, unauthorized but limited access to sensitive information, and affecting the reliable execution of smart contracts also fall under this category.
Severity
- Medium
Description
- Medium severity vulnerabilities could negatively affect the blockchain protocol but are usually not capable of causing catastrophic damage. These could include vulnerabilities that allow minor breaches of user privacy, can slow down transaction processing, or can lead to relatively small financial losses. It may be possible to exploit these vulnerabilities under specific circumstances, or they may require a high level of access to exploit effectively.
Severity
- Low
Description
- Low severity vulnerabilities are minor flaws in the blockchain protocol that might not have a direct impact on security but could cause minor inefficiencies in transaction processing or slight delays in block propagation. They might include vulnerabilities that allow attackers to cause nuisance-level disruptions or are only exploitable under extremely rare and specific conditions. These vulnerabilities should be corrected but do not represent an immediate threat to the system.
Appendix 2. Scope
The scope of the project includes the following components from the provided repository:
Scope Details | |
|---|---|
| Repository | https://github.com/kopi-money/kopi/tree/v22-rc6/x/tokenfactory→ |
| Commit | 0a1232fc4bed69610dc350eb1881f6237c892863 |
| Whitepaper | https://kopi-money.gitbook.io/docs→ |
Scope Details
- Commit
- 0a1232fc4bed69610dc350eb1881f6237c892863
- Whitepaper
- https://kopi-money.gitbook.io/docs→
Components in Scope
The entire tokenfactory module.
Message Definitions & Validation
Keeper Logic & State Management
Persistence Layer & Prefixes
Trading & Fee Mechanics
Metadata Updates & Rate-Limits