There are ERC20 tokens that charge fee for every transfer() or transferFrom().
In the current implementation, sendToCosmos() assumes that the received amount is the same as the transfer amount, and uses it to emit SendToCosmosEvent event.
As a result, when bridging the token back from Cosmos, it may revert because of insufficient balance.
Lines of code
https://github.com/code-423n4/2022-05-cudos/blob/de39cf3cd1f1e1cf211819b06d4acf6a043acda0/solidity/contracts/Gravity.sol#L595-L609
Vulnerability details
There are ERC20 tokens that charge fee for every
transfer()
ortransferFrom()
.In the current implementation,
sendToCosmos()
assumes that the received amount is the same as the transfer amount, and uses it to emitSendToCosmosEvent
event.As a result, when bridging the token back from Cosmos, it may revert because of insufficient balance.
https://github.com/code-423n4/2022-05-cudos/blob/de39cf3cd1f1e1cf211819b06d4acf6a043acda0/solidity/contracts/Gravity.sol#L595-L609
Recommendation
Consider comparing before and after balance to get the actual transferred amount: