EthereumCommonwealth / Auditing

Ethereum Commonwealth Security Department conducted over 400 security audits since 2018. Not even a single contract that we audited was hacked. You can access our audit reports in the ISSUES of this repo. We are accepting new audit requests.
https://audits.callisto.network/
GNU General Public License v3.0
131 stars 34 forks source link

Tether USD (USDT) #320

Closed carlossampol closed 5 years ago

carlossampol commented 5 years ago

Audit request

Audit Top 200 CoinMarketCap tokens.

Tether USD (USDT) Ethereum Token

Deployed at https://etherscan.io/address/0xdac17f958d2ee523a2206206994597c13d831ec7#contracts

Source code

https://etherscan.io/address/0xdac17f958d2ee523a2206206994597c13d831ec7#contracts

Disclosure policy

public

Platform

Ethereum

Number of lines:

252

MrCrambo commented 5 years ago

Auditing time 1 day

yuriy77k commented 5 years ago

@MrCrambo assigned

MrCrambo commented 5 years ago

My report is finished

RideSolo commented 5 years ago

Auditing time: 1 day

yuriy77k commented 5 years ago

@RideSolo assigned

danbogd commented 5 years ago

Auditing time: 1 day.

danbogd commented 5 years ago

My report is finished.

yuriy77k commented 5 years ago

@danbogd assigned

yuriy77k commented 5 years ago

Tether USD (USDT) Security Audit Report

1. Summary

Tether USD (USDT) smart contract security audit report performed by Callisto Security Audit Department

2. In scope

3. Findings

In total, 7 issues were reported including:

No critical security issues were found.

3.1. Owner Privileges

Severity: Owner Privileges

Description

  1. Pause/unpause transfer and transferFrom.
  2. Blacklist users addresses individualy from using transfer and transferFrom through addBlackList and removeBlackList. And burn blacklisted users assets (please note that the assets are supposed to be backed in a 1:1 ratio) using destroyBlackFunds function.
  3. A maximal fee percentage of 20/10000 can be applied per transaction with a maximal value of 50 USDT, check here.
  4. Owner can upgrade contract using deprecate and implement any logic in the new contract. And even if the new contract will be audited, at any time possible to change the address of the new contract again to not audited and insecure.

3.2. Transfer to Address(0)

Severity: low

Description

transfer and transferFrom allow the destination address to be equal to zero, meaning that users fund can be lost if sent to it by mistake.

Code snippet

    function transfer(address _to, uint _value) public onlyPayloadSize(2 * 32) {
        uint fee = (_value.mul(basisPointsRate)).div(10000);
        if (fee > maximumFee) {
            fee = maximumFee;
        }
        uint sendAmount = _value.sub(fee);
        balances[msg.sender] = balances[msg.sender].sub(_value);
        balances[_to] = balances[_to].add(sendAmount);
        if (fee > 0) {
            balances[owner] = balances[owner].add(fee);
            Transfer(msg.sender, owner, fee);
        }
        Transfer(msg.sender, _to, sendAmount);
    }
    function transferFrom(address _from, address _to, uint _value) public onlyPayloadSize(3 * 32) {
        var _allowance = allowed[_from][msg.sender];

        uint fee = (_value.mul(basisPointsRate)).div(10000);
        if (fee > maximumFee) {
            fee = maximumFee;
        }
        if (_allowance < MAX_UINT) {
            allowed[_from][msg.sender] = _allowance.sub(_value);
        }
        uint sendAmount = _value.sub(fee);
        balances[_from] = balances[_from].sub(_value);
        balances[_to] = balances[_to].add(sendAmount);
        if (fee > 0) {
            balances[owner] = balances[owner].add(fee);
            Transfer(_from, owner, fee);
        }
        Transfer(_from, _to, sendAmount);
    }

3.3. Not Emitted Transfer Event

Severity: low

Description

When issuing or redeeming tokens a transfer event should be emitted back and forth to address(0). ERC20 standard: "A token contract which creates new tokens SHOULD trigger a Transfer event with the _from address set to 0x0 when tokens are created". the same can be deducted when redeeming or burning tokens.

Same issue is applicable for TetherToken constructor.

Code snippet

https://gist.github.com/RideSolo/24c79eb34b565ade477ec89c2af49a5b#file-usdt-sol-L406

https://gist.github.com/RideSolo/24c79eb34b565ade477ec89c2af49a5b#file-usdt-sol-L420

3.4. Known vulnerabilities of ERC-20 token

Severity: low

Description

  1. It is possible to double withdrawal attack. More details here
  2. Lack of transaction handling mechanism issue. WARNING! This is a very common issue and it already caused millions of dollars losses for lots of token users! More details here

Recommendation

Add into the function transfer(address _to, ... ) and transferFrom the following code, to avoid transfers to the contract address:

   require( _to != address(this) );

4. Conclusion

The audited smart contract can be deployed. Only low severity issues were found during the audit.

5. Revealing audit reports

https://gist.github.com/yuriy77k/49b74a164bccac9b2554de9b25ffae8b

https://gist.github.com/yuriy77k/476b9556f4895d32867890af4e4199ba

https://gist.github.com/yuriy77k/d75e9365b6ec7eefd46a237d09e673bc

MillianoConti commented 5 years ago

Reddit Announced

HawaiiToastNo1 commented 2 years ago

0xdac17f958d2ee523a2206206994597c13d831ec7 - this smart contract has stolen my 50k USDT funds from Trust Wallet!

kostapsimoulis commented 2 months ago

@HawaiiToastNo1 were you ever able to get it back?