The documentation describes the use of tokens other than CUDOS in the Gravity.sol contract; so it is assumed that the CUDOS token will not be the only supported token. The documentation also states that validators on the Tendermint chain will use the information in the emitted event for the sendToCosmos function to determine the amount of tokens to be minted on the Tendermint side.
For transfer-on-fee/deflationary tokens, where the final _amount emitted may not be the same as the _amount in, the emitted amount value in SendToCosmosEvent could be incorrect. This could result in a mismatch of the balance between the Ethereum side and the Tendermint side for the account.
Proof of Concept
Ethereum Account sends 100 tokens (transfer-on-fee tokens) to Gravity.sol using the sendToCosmos function.
After the transfer, the amount of tokens actually sent to Gravity.sol is less than _amount (eg. 90 tokens).
The sendToCosmos function emits the original amount (100 tokens).
The validators on the Tendermint side use the emitted amount (100 tokens) value to determine how many tokens to mint instead of the actual amount received by Gravity.sol.
Tools Used
Recommended Mitigation Steps
Check the balance of the Gravity contract before the transfer and again after the transfer in sendToCosmos. The emitted amount should be the difference of the 2 balances.
Lines of code
Gravity.sol#L595-L609
Vulnerability details
Impact
The documentation describes the use of tokens other than CUDOS in the
Gravity.sol
contract; so it is assumed that the CUDOS token will not be the only supported token. The documentation also states that validators on the Tendermint chain will use the information in the emitted event for thesendToCosmos
function to determine the amount of tokens to be minted on the Tendermint side.For transfer-on-fee/deflationary tokens, where the final
_amount
emitted may not be the same as the_amount
in, the emitted amount value inSendToCosmosEvent
could be incorrect. This could result in a mismatch of the balance between the Ethereum side and the Tendermint side for the account.Proof of Concept
Gravity.sol
using thesendToCosmos
function.Gravity.sol
is less than_amount
(eg. 90 tokens).sendToCosmos
function emits the original amount (100 tokens).Gravity.sol
.Tools Used
Recommended Mitigation Steps
Check the balance of the Gravity contract before the transfer and again after the transfer in
sendToCosmos
. The emitted amount should be the difference of the 2 balances.