code-423n4 / 2024-05-canto-findings

0 stars 0 forks source link

upgradetypes.ModuleName has been mistakenly added to SetOrderBeginBlockers #21

Closed howlbot-integration[bot] closed 5 months ago

howlbot-integration[bot] commented 5 months ago

Lines of code

https://github.com/code-423n4/2024-05-canto/blob/main/canto-main/app/app.go#L823 https://github.com/code-423n4/2024-05-canto/blob/main/ethermint-main/app/app.go#L695

Vulnerability details

Description

According to the upgrading guide of cosmos sdk for version 0.50.6, when using (legacy) application wiring, the following must be added to app.go:

+app.ModuleManager.SetOrderPreBlockers(
+   upgradetypes.ModuleName,
+)

app.ModuleManager.SetOrderBeginBlockers(
-   upgradetypes.ModuleName,
)

However, in the app.go of Canto and Ethermint, the upgradetypes.ModuleName under SetOrderBeginBlockers has not been removed.

Canto App
File: app.go
823:        upgradetypes.ModuleName, //@audit should be removed? 

Ethermint App
File: app.go
668:        upgradetypes.ModuleName,//@audit should be removed

Impact

Running the same module twice in a single block cycle can introduce unnecessary computational overhead. This redundancy can slow down block processing without adding any benefit.

Proof of Concept

Consider this scenario, in every block processing, upgradetypes.ModuleName will be executed twice, one in preblock phase and one in beginblock phase. This will delay the overall performance of Canto blockchain as well as unnecessary consumption of resources.

Tools Used

Manual Review

Recommended Mitigation Steps

Remove the upgradetypes.ModuleName under SetOrderBeginBlockers as per upgrade guide.

Assessed type

Other

poorphd commented 5 months ago
3docSec commented 5 months ago

I agree with the sponsor. The finding is inconsequential because for a hook to be called, the module needs to implement the right interface. And because x/upgrade doesn't, the SetOrderBeginBlockers call has no effect

c4-judge commented 5 months ago

3docSec marked the issue as unsatisfactory: Invalid