-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Attacker has the ability to send funds to module address, potentially breaking blockchain invariants and halting the network #2158
Comments
I reported the same vulnerability on Code4rena, but SendCoins was not modified. I suspect this report was disregarded. However, I still believe that it's necessary to validate the toAddr within the SendCoins function |
Why does it matter if you can send funds to a module account. That's perfectly valid It looks like you're referring to an issue similar to this one from 6 years ago: cosmos/cosmos-sdk#4795. Is there an example of a module account with the modern Cosmos-SDK where it's bad to send it funds? |
https://medium.com/@jjordanjjordan/150-000-evmos-vulnerability-through-reading-documentation-d26328590a7a |
https://github.com/evmos/evmos/blob/main/app/app.go#L963 func initBankKeeper(appCodec codec.Codec, keys map[string]*sdk.KVStoreKey, keepers *KeeperCache, moduleAccPerms map[string][]string) *bankkeeper.BaseKeeper {
bankK := bankkeeper.NewBaseKeeper(
appCodec,
keys[banktypes.StoreKey],
GetKeeper[authkeeper.AccountKeeper](keepers),
keepers.getSubspace(banktypes.ModuleName),
maps.Filter(moduleAccountAddrs(moduleAccPerms), func(addr string, _ bool) bool {
// we do not rely on internal balance tracking for invariance checks in the nexus module
// (https://github.com/cosmos/cosmos-sdk/issues/12825 for more details on the purpose of the blocked list),
// but the nexus module account must be able to send or receive coins to mint/burn them for cross-chain transfers,
// so we exclude this address from the blocked list
return addr != authtypes.NewModuleAddress(nexusTypes.ModuleName).String()
}),
)
return &bankK
} https://github.com/axelarnetwork/axelar-core/blob/main/app/keepers.go#L440 https://github.com/maticnetwork/heimdall/blob/master/bank/handler.go#L25 Since this is code from several years ago. Module address allowed recive funds |
By the way,I have reported same report on code4rena. auther name is stonejiajia, If my report is classified as invalid, can it be reclassified as valid? The severity level is high. |
Yes, will communicate with the judges and Code4rena. This GitHub issue provides a nice summary for them to review as well. Edit: Oh, I see why C4's marked it the way they did. The code you've highlighted in |
According to the principle of defense in depth, I believe SendCoins should be modified. SendCoins doesn't validate toAddr. In any case, I still believe my report is valid and reasonable. From this issue, it can be seen that you used SendCoins, which caused harm. |
Yes, it's a valid issue. I think Code4rena only removed it from the competition because that code wasn't in the codebase for the audit's commit hash. I'm still more in favor of using the As for the vulnerability, I'll discuss with the team do a bug bounty |
Thank you for your understanding , If you do provide bug bounties, my email is [email protected], please use this method to contact me. |
Root Cause
A critical vulnerability in the bankMsgSend precompile function allows attackers to send funds directly to module address. This capability can potentially break blockchain invariants and lead to a network halt. The lack of proper checks in the function enables malicious actors to disrupt the expected state of the system, posing a severe threat to the network's stability and integrity.
The vulnerability is triggered through the following execution path:
FunTokenMethod_bankMsgSend -> bankMsgSend -> sendCoins -> sendCoins ( cosmos )
The final step uses the Cosmos bank keeper function SendCoins. In Cosmos, there is no validation of the toAddr in SendCoins. Only the send function validates the toAddr
Document Explain that:
Internal pre-conditions
bankMsgSend
precompile function needs to be active and accessible in the EVM environment.Attack Path:
bankMsgSend
precompile function, specifying the module account as the recipient.Impact
The protocol suffers a potential loss of funds in module accounts, which could lead to broken invariants and network halts.
The text was updated successfully, but these errors were encountered: