Submitted by peachtea, also found by Audinarey, carrotsmuggler, Egis_Security, and p0wd3r
Attackers can fund rewards of LP tokens with tokens created from the x/tokenfactory module and abuse the MsgForceTransfer message to prevent the contract from successfully distributing rewards. This would also prevent the contract owner from closing the malicious farm. As a result, rewards that are accrued to the users will be stuck in the contract, causing a loss of rewards.
When a user claims pending rewards of their LP tokens, all of their rewards are aggregated together and sent within a BankMsg::Send message. 
/contracts/farm-manager/src/farm/commands.rs#L102-L107
These rewards can be funded externally via the FarmAction::Fill message for a particular LP asset.
One thing to note is that the reward must be a Coin, which means it must be a native token recognized by the Cosmos SDK module.
https://github.com/code-423n4/2024-11-mantra-dex/blob/26714ea59dab7ecfafca9db1138d60adcf513588/packages/amm/src/farm_manager.rs#L186-L187
The Mantra DEX contract will be deployed in the Mantra chain, which is running in parallel as another competition here. The Mantra chain implements a x/tokenfactory module to allow token creators to create native tokens.
https://github.com/MANTRA-Chain/mantrachain/blob/v1.0.2/x/tokenfactory/keeper/msg_server.go
One of the features in the x/tokenfactory module is that token creators can call the MsgForceTransfer to forcefully transfer funds from one account to another account, effectively reducing its balance.
https://github.com/MANTRA-Chain/mantrachain/blob/v1.0.2/x/tokenfactory/keeper/msg_server.go#L149
This allows an attacker to perform a denial of service of the rewards pending in the contract by supplying a tokenfactory denom, and then forcefully transfer funds from the contract in order to cause an insufficient funds error.
To mitigate this attack, consider modifying the close_farms function so the messages are dispatched as SubMsg::reply_on_error when refunding the rewards to the farm owner. Within the reply handler, simply return an Ok(Response::default()) if an error occurred during BankMsg::Send. This will prevent the attack because the contract owner will still have the power to close malicious farms even though the attacker reduced the contracts balance.
https://docs.rs/cosmwasm-std/latest/cosmwasm_std/struct.SubMsg.html#method.reply_on_error
jvr0x (MANTRA) confirmed
3docSec (judge) commented:
