xfeemarket module is not wired up, resulting in non-working CLI commands, message server, genesis export
The custom xfeemarket module was not registered in the Cosmos SDK app, so its CLI commands, message server, and genesis export/import did not work. This prevented configuring fee multipliers to use multiple coin denoms as gas fees.
berndartmueller Follow with abdulsamijay and Egis_Security
Originally disclosed on Code4rena
Submitted by berndartmueller, also found by abdulsamijay and Egis_Security
Finding description and impact
A Cosmos SDK app is set up in app/app.go, where all modules are wired up. Some of the steps include:
module.NewManager(..)initializes the module manager. For example, it ensures that the module’s CLI commands are registered and available from the binarygenesisModuleOrderspecifies the order of the modules for exporting and initializing genesis statestoretypes.NewKVStoreKeys(..)registers all the store keys for the various modules
However, it has been observed that Mantra’s custom xfeemarket module is not properly registered. It is missing in the steps above. As a result, the module’s CLI commands are not available and do not work. The message server is not registered, which prevents, for example, using the MsgUpsertFeeDenom and MsgRemoveFeeDenom messages to update the fee multipliers. The module’s state is not exported or initialized in the genesis state.
This prevents the module from being fully functional, especially from configuring fee multipliers to be able to use various coin denoms as gas fees.
Proof of Concept
For example, storetypes.NewKVStoreKeys(..) registers all the store keys for the various modules. However, Mantra’s custom xfeemarket module is not included in that list.
308: keys := storetypes.NewKVStoreKeys(
309: authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, crisistypes.StoreKey,
310: minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
311: govtypes.StoreKey, paramstypes.StoreKey, consensusparamtypes.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
312: evidencetypes.StoreKey,
313: circuittypes.StoreKey,
314: authzkeeper.StoreKey,
315: nftkeeper.StoreKey,
316: group.StoreKey,
317: // non sdk store keys
318: capabilitytypes.StoreKey, ibcexported.StoreKey, ibctransfertypes.StoreKey, ibcfeetypes.StoreKey,
319: wasmtypes.StoreKey,
320: ratelimittypes.StoreKey,
321: tokenfactorytypes.StoreKey, taxtypes.StoreKey,
322: ibchookstypes.StoreKey,
323: feemarkettypes.StoreKey, oracletypes.StoreKey, marketmaptypes.StoreKey,
324: )
Recommended mitigation steps
To ensure that the custom xfeemarket module is fully functional, consider the following diff to wire up the module in app/app.go:
diff --git a/app/app.go b/app/app.go
index bfaa4a7..7f4d4bb 100644
--- a/app/app.go
+++ b/app/app.go
@@ -43,6 +43,8 @@ import (
"github.com/MANTRA-Chain/mantrachain/x/tokenfactory"
tokenfactorykeeper "github.com/MANTRA-Chain/mantrachain/x/tokenfactory/keeper"
tokenfactorytypes "github.com/MANTRA-Chain/mantrachain/x/tokenfactory/types"
+ xfeemarketkeeper "github.com/MANTRA-Chain/mantrachain/x/xfeemarket/keeper"
+ xfeemarket "github.com/MANTRA-Chain/mantrachain/x/xfeemarket/module"
xfeemarkettypes "github.com/MANTRA-Chain/mantrachain/x/xfeemarket/types"
abci "github.com/cometbft/cometbft/abci/types"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
@@ -254,8 +256,9 @@ type App struct {
ScopedFeeabsKeeper capabilitykeeper.ScopedKeeper
// MANTRAChain keepers
- TokenFactoryKeeper tokenfactorykeeper.Keeper
- TaxKeeper taxkeeper.Keeper
+ TokenFactoryKeeper tokenfactorykeeper.Keeper
+ TaxKeeper taxkeeper.Keeper
+ CustomFeeMarketKeeper xfeemarketkeeper.Keeper
// the module manager
ModuleManager *module.Manager
@@ -321,6 +324,7 @@ func New(
tokenfactorytypes.StoreKey, taxtypes.StoreKey,
ibchookstypes.StoreKey,
feemarkettypes.StoreKey, oracletypes.StoreKey, marketmaptypes.StoreKey,
+ xfeemarkettypes.StoreKey,
)
tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey)
@@ -564,6 +568,14 @@ func New(
authtypes.FeeCollectorName,
)
+ app.CustomFeeMarketKeeper = xfeemarketkeeper.NewKeeper(
+ appCodec,
+ runtime.NewKVStoreService(keys[xfeemarkettypes.StoreKey]),
+ logger,
+ authtypes.NewModuleAddress(govtypes.ModuleName).String(),
+ app.BankKeeper,
+ )
+
app.FeeMarketKeeper = feemarketkeeper.NewKeeper(
appCodec, keys[feemarkettypes.StoreKey],
app.AccountKeeper,
@@ -759,6 +771,7 @@ func New(
tokenfactory.NewAppModule(appCodec, app.TokenFactoryKeeper),
tax.NewAppModule(appCodec, app.TaxKeeper),
feemarket.NewAppModule(appCodec, *app.FeeMarketKeeper),
+ xfeemarket.NewAppModule(appCodec, app.CustomFeeMarketKeeper, app.AccountKeeper, app.BankKeeper),
)
// BasicModuleManager defines the module BasicManager is in charge of setting up basic,
@@ -811,6 +824,7 @@ func New(
tokenfactorytypes.ModuleName,
oracletypes.ModuleName,
marketmaptypes.ModuleName,
+ xfeemarkettypes.ModuleName,
)
app.ModuleManager.SetOrderEndBlockers(
@@ -833,6 +847,7 @@ func New(
taxtypes.ModuleName,
oracletypes.ModuleName,
marketmaptypes.ModuleName,
+ xfeemarkettypes.ModuleName,
)
// NOTE: The genutils module must occur after staking so that pools are
@@ -881,6 +896,7 @@ func New(
// market map genesis must be called AFTER all consuming modules (i.e. x/oracle, etc.)
oracletypes.ModuleName,
marketmaptypes.ModuleName,
+ xfeemarkettypes.ModuleName,
}
app.ModuleManager.SetOrderInitGenesis(genesisModuleOrder...)
app.ModuleManager.SetOrderExportGenesis(genesisModuleOrder...)
Looks valid.
Lance Lan (MANTRA) acknowledged and commented:
Intended behavior. Will only be wired in future when we want to support multi fee denoms.
berndartmueller (warden) commented:
According to the audit readme,
“Multi-token support for transaction fees”
is one of the listed features of Mantra Chain. Thus, it can be assumed that any issues related to preventing the use of other fee coins for gas payments are valid and their severity should be evaluated accordingly. There is also no hint that this feature will only be used later in the future.
Therefore, I would like the judge to reconsider the severity of this issue and consider Medium severity.
The rules we have on speculation on future code (or in this case future configuration, that is enabling support for multi-token transaction fees) are clear: the feature is in scope unless said otherwise in the audit README.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
The module was not fully functional, preventing configuration of fee multipliers to use various coin denoms as gas fees.
What the attacker needed
None
The fix
The module should be wired up in app/app.go by adding its store key, keeper, module, and genesis order entries.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
In a Cosmos SDK blockchain, each module must be explicitly connected in the main application file. If a module is left out, its commands and messages are not available, so users cannot use its features. Here, the fee market module was left out, so the ability to pay gas fees with different coins did not work.
What is Misconfiguration?
Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.