Non-Cudos Erc20 funds sent through sendToCosmos() will be lost.
The sendToCosmos function accepts any ERC20 token without checking if it is supported, so users who send non-Cudos tokens lose their funds because the contract does not credit them on the destination chain. The admin can later withdraw these tokens, but the user has no way to recover them.
Submitted by p_crypt0, also found by CertoraInc
No checks for non-Cudos tokens mean that non-Cudos ERC20 tokens will be lost to the contract, with the user not having any chance of retrieving them.
However, the admin can retrieve them through withdrawERC20.
Impact is that users lose their funds, but admins gain them.
The mistakes could be mitigated on the contract, by checking against a list of supported tokens, so that users don’t get the bad experience of losing funds and CUDOS doesn’t have to manually refund users
Proof of Concept
User sends 100 ETH through sendToCosmos, hoping to retrieve 100 synthetic ETH on Cudos chain but finds that funds never appear.
function sendToCosmos(
address _tokenContract,
bytes32 _destination,
uint256 _amount
) public nonReentrant {
IERC20(_tokenContract).safeTransferFrom(msg.sender, address(this), _amount);
state_lastEventNonce = state_lastEventNonce.add(1);
emit SendToCosmosEvent(
_tokenContract,
msg.sender,
_destination,
_amount,
state_lastEventNonce
);
}
Admin can retrieve these funds should they wish, but user never gets them back because the contract does not check whether the token is supported.
function withdrawERC20(
address _tokenAddress)
external {
require(cudosAccessControls.hasAdminRole(msg.sender), "Recipient is not an admin");
uint256 totalBalance = IERC20(_tokenAddress).balanceOf(address(this));
IERC20(_tokenAddress).safeTransfer(msg.sender , totalBalance);
}
Tools Used
Logic and discussion with @germanimp (Cudos)
Recommended Mitigation Steps
Add checks in sendToCosmos to check the incoming tokenAddress against a supported token list, so that user funds don’t get lost and admin don’t need to bother refunding.
V-Staykov (Cudos) resolved and commented:
Note: there were originally 7 items judged as Medium severity. After judging was finalized, further input from the sponsor was provided to the judge for reconsideration. Ultimately, the judge decreased issue #143 to non-critical.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the sendToCosmos function lacks a check that the token address is in a supported token list, so any ERC20 token can be transferred in without being credited to the user on the destination chain.
Impact
Users lose their funds, but admins gain them; the admin can retrieve the tokens through withdrawERC20, but the user cannot.
What the attacker needed
User sends a non-Cudos ERC20 token; User calls sendToCosmos
The fix
The contract should be fixed by checking the incoming token address against a supported token list in sendToCosmos.
How it was found
- User calls sendToCosmos with a non-Cudos ERC20 token address and an amount.
- The contract transfers the tokens from the user to itself.
- The contract emits an event but does not credit the user on the Cudos chain.
- The user's funds are stuck in the contract and cannot be retrieved by the user.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
This is a smart contract that lets you send tokens to another blockchain. It does not check if the token you send is one it supports, so if you send the wrong token, it gets stuck in the contract and you cannot get it back. Only the admin can take stuck tokens out.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.