Protocol fees are mistakenly configured by protocol pools rather than being imposed
The protocol fee for swaps is set by pool creators when creating a pool, allowing them to set it to zero. This means the protocol may not collect the swap fees it is entitled to.
Originally disclosed on Code4rena
Submitted by Abdessamed
/contracts/pool-manager/src/manager/commands.rs#L81
Impact
For every swap operation, the protocol is entitled to a get fees from the tokens out, the sponsor has confirmed that fees should be taken for every swap. However, the current implementation incorrectly gives the protocol_fee control to pool creators when creating pool:
pub fn create_pool(
deps: DepsMut,
env: Env,
info: MessageInfo,
asset_denoms: Vec<String>,
asset_decimals: Vec<u8>,
pool_fees: PoolFee,
pool_type: PoolType,
pool_identifier: Option<String>,
) -> Result<Response, ContractError> {
// --SNIP
POOLS.save(
deps.storage,
&identifier,
&PoolInfo {
pool_identifier: identifier.clone(),
asset_denoms,
pool_type: pool_type.clone(),
lp_denom: lp_asset.clone(),
asset_decimals,
pool_fees,
assets,
},
)?;
}
Pool creators can specify 0 fees for pool_fees.protocol_fee, causing the protocol to lose swap fees they are entitled to.
Recommended mitigation steps
Consider moving the protocol_fee to the contract’s config, rather than being controlled by pool creators.
jvr0x (MANTRA) confirmed
Looks valid, probably Low though, as there is no impact on users.
This should be Low/info at most because
pool_fees.protocol_feeis a “frontend” fee (i.e., a fee charged for using the user interface that facilitates interaction with these contracts). This is common in many protocols.The main fees, which are also implemented correctly (and fetched from the config), are the pool creation fee and the token factory fee.
Abdessamed (warden) commented:
@DadeKuma - the fees you are talking about are the pool creation fees, which is implemented correctly and the report does not speak about these fees at all.
What the report is highlighting is that the swap fees are given control to the pool creators mistakenly rather than being imposed by the protocol’s configuration whereby pool creators can simply put zero fees for the protocol team to prevent them from taking swap fees for whatever reason. The sponsor intends to take fees from every swap operation to collect revenue, which is not implemented.
@3docSec - there is no impact for pool creators but at the expense of protocol losses. The protocol team intends to collect revenue from swap fees (like Uniswap and other AMMs do), and not receiving those fees is a clear loss for the protocol team, and thus, this report is eligible for Medium severity.
@Abdessamed - I agree. I do not think this is a likely attack vector because the protocol can:
- Force through the UI a proper value if creators create pools through the UI.
- Not show in the UI pools that don’t have an adequate protocol fee for swap users.
We are a bit borderline here because of likelihood, but Medium seems justified to me.
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
The protocol fee is stored per pool and set by the pool creator during pool creation, instead of being a global configuration controlled by the protocol.
Impact
The protocol may lose swap fee revenue because pool creators can set the protocol fee to zero.
What the attacker needed
Pool creator sets protocol fee to zero
The fix
The protocol fee should be moved to the contract's configuration so it is not controlled by pool creators.
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.
When someone creates a trading pool, they can choose a fee that goes to the protocol. The problem is that they can set this fee to zero, so the protocol gets no money from trades. The protocol team wanted to always get a cut, but the code lets pool creators decide.
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.