Multiplier is calculated using denom and not coin.Denom
The fee market resolver incorrectly fetches the denomination multiplier using the target denom instead of the coin's own denom, so conversions between non-base coins use the wrong multiplier. An attacker could exploit this to pay incorrect fees, but the resolver is not currently wired in and the feature is not active.
ABAIKUNANBAEV Follow with berndartmueller
Originally disclosed on Code4rena
Submitted by ABAIKUNANBAEV, also found by berndartmueller
Finding description and impact
Currently, there is a resolver that helps to convert different coins to the corresponding amount of the base coin to ensure multiple fee coin market can be supported. However, it incorrectly fetches the multiplier using the base denom instead of taking denom of the denom in the function.
Proof of Concept
Take a look at how multiplier is now derived:
https://github.com/code-423n4/2024-11-mantra/blob/main/x/xfeemarket/keeper/resolver.go#L11-23
func (k Keeper) ConvertToDenom(ctx sdk.Context, coin sdk.DecCoin, denom string) (sdk.DecCoin, error) {
if coin.Denom == denom {
return coin, nil
}
multiplier, err := k.DenomMultipliers.Get(ctx, denom)
if err != nil {
return sdk.DecCoin{}, err
}
amount := coin.Amount.Mul(multiplier.Dec)
return sdk.NewDecCoinFromDec(denom, amount), nil
}
As you can see here, it fetches multiplier by putting denom in the mapping that’s stored in the feemarket keeper:
https://github.com/code-423n4/2024-11-mantra/blob/main/x/xfeemarket/keeper/keeper.go#L28-29
// DenomMultipliers is a map of denomination and their multipliers against the default base fee denomination.
DenomMultipliers collections.Map[string, sdk.DecProto]
So this mapping serves as a way to get the corresponding denom => multiplier against the default base fee denomination. The problem is that currently it’s the base denom that’s provided in the Get() function:
multiplier, err := k.DenomMultipliers.Get(ctx, denom)
Instead, it has to take coin.Denom as the previous line makes sure that the denom is not the base one:
if coin.Denom == denom {
return coin, nil
}
This results in a situation where we take the multiplier for a base denom instead of taking it for the denom that’s used against the base one.
Recommended mitigation steps
Change the current functionality on the following line:
https://github.com/code-423n4/2024-11-mantra/blob/main/x/xfeemarket/keeper/resolver.go#L16
multiplier, err := k.DenomMultipliers.Get(ctx, coin.Denom)
Plausible, can’t exclude a misunderstanding.
Lance Lan (MANTRA) confirmed and commented:
Indeed a error. But this resolver is not wired in and is not used. It is not the final implementation thus Low.
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
Root cause
Likely the code passes the target denom to the multiplier lookup instead of the source coin's denom.
Impact
The resolver is not wired in and not used, so the incorrect multiplier has no current impact; if enabled, it could cause incorrect fee conversions.
What the attacker needed
Resolver must be wired in and used
The fix
The multiplier lookup should use the coin's own denom instead of the target denom.
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.
This is a smart contract audit finding about a fee conversion function. The function is supposed to look up a multiplier for the coin being converted, but it looks up the multiplier for the target denomination instead. That means the wrong number is used when calculating how much of one coin equals another, which could let someone pay the wrong fee.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.