Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
EVENT BUG
This is one of the BUGs that IRISnet team reported to security@cosmosnetwork.dev, but it seems that it has not been fixed. Hacker can use this bug to attack other nodes in the network, thereby improving its ranking in the game (however we did not do so), this bug has a very serious impact on the entire schedule of GoZ!
Bug Description
When a Tx contains multiple ICS-20 messages, the events will be abnormal. The reason is that the following msg events will contain all the previous msg events. You can see the event
logs.events.type='send_packet'
here: https://gist.github.com/SegueII/401de4d690a0a40038ad21a4ed2536eaThis is an example using one, two and three MSGs in one Tx.
Because of event error,so
relayPacketFromQueryResponse(...)
can't get the correct result. https://github.com/iqlusioninc/relayer/blob/master/relayer/naive-strategy.go#L320We fixed this problem in relayer, making it possible to query the packet correctly. But more serious problems were found in the next test: When there are fewer msgs in one Tx, no exception will occur, but if the number of MSGs in a single Tx is big, the event data will be very, very large, and even cause node memory overflow during query.
If a Tx contains dozens or even hundreds of MSGs, when using multi-goroutine call
TxSearch(...)
, the following error will be caused, and the node memory will explode. In my PC, gaia's memory usage will exceed 20G.You can see the err log here: https://gist.github.com/SegueII/d9c543c92cc6dde7d8d5a75e6eae6ba1
In
phase-1b
, this BUG can be used to attack the public RPC nodes, which will have a greater impact on the game results. Attacks can also be easily launched inphase-2
andphase-3
, by sending transactions containing a large number of MSGs to the channels of other teams, making their relayer query timeout and unable to relay packet.The fix method is very simple, just add
ctx = ctx.WithEventManager(sdk.NewEventManager())
toNewHandler()
in ICS-20 module.