Farseen0/scar-pairs huggingface dataset:
MEDIUM severity: Old ERC20 Token implementation. Deprecated and vulnerable to withdrawal attacks

Vulnerable code:
pragma solidity 0.4.25;

import "./ERC20.sol";
import "../Common/Upgradable.sol";

contract Gold is ERC20, Upgradable {
    uint256 constant DEVS_STAKE = 6; // 1/6

    address[5] founders = [
        0x23b3763f31F4da6B42F47927BCF66A221E8705Cd,
        0x5CFF40372b96e133967d980F72812653163121fa,
        0xE246C5Aa2D57878DA70779A75B12dCDFFd77aDBA,
        0x950eEAf8ddbA1409dbD25aD16d50A867EEA75c3E,
        0x87252E8F04F6c6bC4d2c690893addb7108aa8a5f
    ];

    address foundation = 0x5Ff8957EF7e964E8072815211c9Fc3E7F820F1D4;
    address NonsenseGames = 0x10208FB4Ef202BdC49803995b0A8CA185383bba4;

    string constant WP_IPFS_HASH = "QmfR75tK12q2LpkU5dzYqykUUpYswSiewpCbDuwYhRb6M5";


    constructor(address treasury) public {
        name = "Dragonereum Gold";
        symbol = "GOLD";
        decimals = 18;

        uint256 _foundersGold = 6000000 * 10**18; // 10%
        uint256 _foundationGold = 6000000 * 10**18; // 10%
        uint256 _NonsenseGamesGold = 3000000 * 10**18; // 5%
        uint256 _gameAccountGold = 45000000 * 10**18; // 75%

        uint256 _founderStake = _foundersGold.div(founders.length);
        for (uint256 i = 0; i < founders.length; i++) {
            _mint(founders[i], _founderStake);
        }

        _mint(foundation, _foundationGold);
        _mint(NonsenseGames, _NonsenseGamesGold);
        _mint(treasury, _gameAccountGold);

        require(_totalSupply == 60000000 * 10**18, "wrong total supply");
    }

    function remoteTransfer(address _to, uint256 _value) external onlyController {
        _transfer(tx.origin, _to, _value); // solium-disable-line security/no-tx-origin
    }

    function burn(uint256 _value) external onlyController {
        _burn(msg.sender, _value);
    }
}


Vulnerability type: CWE-664|CWE-1329
MEDIUM severity: Constructor overwhelmed. The code can fail if a list of token receivers is big enough.

Vulnerable code:
//SPDX-License-Identifier: MIT

pragma solidity 0.8.12;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Capped.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";

/// @title List futures unlockable after a year
/// @author Noah Jelich
/// @notice The LISTFuture tokens are replacable 1:1 for LIST tokens 1 year after the fair launch
/// @dev The main use of this contract is for the team tokens, which constitute 10% of the tokens
contract LISTFuture is ERC20Capped, Ownable, Pausable {
  struct Balance {
    address account;
    uint256 amount;
  }

  /// @dev the number of team addresses is going to be less than a dozen
  /// @param cap set to 10% of the LIST token cap
  /// @param balances team addresses that will be receiving shares
  constructor(uint256 cap, Balance[] memory balances) ERC20("CryptoToday Futures", "$LISTF") ERC20Capped(cap) {
    for (uint256 i = 0; i < balances.length; i++) {
      _mint(balances[i].account, balances[i].amount);
    }
  }

  /// @notice burn function to be used when converting futures into proper LIST tokens
  function burnFrom(address account, uint256 amount) public virtual {
    uint256 currentAllowance = allowance(account, _msgSender());
    require(currentAllowance >= amount, "ERC20: burn amount exceeds allowance");
    unchecked {
      _approve(account, _msgSender(), currentAllowance - amount);
    }
    _burn(account, amount);
  }
}


Vulnerability type: CWE-703|CWE-754
MEDIUM severity: Syntax error. HedgeyCallsFactory contract has an excess “/” symbol before the “import” statement.

Vulnerable code:
pragma solidity ^0.6.12;

import "./HedgeyCalls.sol"


contract HedgeyCallsFactory {
    
    mapping(address => mapping(address => address)) public pairs;
    address payable public collector;
    uint public fee;
    mapping(address => bool) private swappers;
    
    

    constructor (address payable _collector, uint _fee) public {
        collector = _collector;
        fee = _fee;
       
    }
    
    function addSwapper(address swapper) external {
        require(msg.sender == collector, "youre not the collector");
        swappers[swapper] = true;
    }

    function isSwapper(address swapper) external view returns (bool check) {
        check = swappers[swapper];
    }
    
    
    function changeFee(uint _newFee, address payable _collector) external {
        require(msg.sender == collector, "youre not the collector");
        fee = _newFee;
        collector = _collector;
    }
    
    
    function getPair(address asset, address pymtCurrency) external view returns (address pair) {
        pair = pairs[asset][pymtCurrency];
    }
   
    
    function createContract(address asset, address pymtCurrency) external {
        require(asset != pymtCurrency, "same currencies");
        require(pairs[asset][pymtCurrency] == address(0), "contract exists");
        HedgeyCalls callContract = new HedgeyCalls(asset, pymtCurrency, collector, fee);
        pairs[asset][pymtCurrency] = address(callContract);
        emit NewPairCreated(asset, pymtCurrency, address(callContract));
    }

    event NewPairCreated(address _asset, address _pymtCurrency, address _pair);
}



Vulnerability type: CWE-710
MEDIUM severity: Admin could mint unlimited tokens. The admin has unlimited minting ability for tokens, which can be risky for the market price.

Vulnerable code:
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "./utils/AccessProtected.sol";
import "@openzeppelin/contracts/utils/Pausable.sol";

// Tera Block Token
contract TeraBlockToken is ERC20("TeraBlock Token", "TBC"), AccessProtected, Pausable {
    address public depositAdmin;

    function mint(address to, uint256 amount) external onlyAdmin whenNotPaused {
        _mint(to, amount);
    }

    function burn(uint256 _amount) external whenNotPaused {
        _burn(_msgSender(), _amount);
    }

    function deposit(address user, bytes calldata depositData) external whenNotPaused {
        require(_msgSender() == depositAdmin, "sender != depositAdmin");
        uint256 amount = abi.decode(depositData, (uint256));
        _mint(user, amount);
    }

    function setDepositAdmin(address _depositAdmin) external onlyAdmin whenNotPaused {
        depositAdmin = _depositAdmin;
    }

    /// Withdraw any IERC20 tokens accumulated in this contract
    function withdrawTokens(IERC20 _token) external onlyOwner {
        _token.transfer(owner(), _token.balanceOf(address(this)));
    }

    function getOwner() external view returns (address) {
        return owner();
    }

    //
    // IMPLEMENT PAUSABLE FUNCTIONS
    //
    function pause() external onlyOwner {
        _pause();
    }

    function unpause() external onlyOwner {
        _unpause();
    }
}


Vulnerability type: CWE-284|CWE-269
MEDIUM severity: staticall uses a hardcoded address to verify the signature. The contract uses a hardcoded address (0x8001) for verification, which may lead to reverts and security vulnerabilities.

Vulnerable code:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import "../../interfaces/ISecp256r1.sol";

contract Secp256r1 is ISecp256r1 {
    function validateSignature(
        bytes32 message,
        bytes calldata signature,
        bytes calldata publicKey
    ) external view override returns (bool result) {
        bytes32 rs0;
        bytes32 rs1;
        bytes32 Q0;
        bytes32 Q1;

        (rs0, rs1) = abi.decode(signature, (bytes32, bytes32));
        (Q0, Q1) = abi.decode(publicKey, (bytes32, bytes32));

        bytes1 out;
        assembly {
            // free memory pointer
            let input := mload(0x40)

            mstore(input, message)
            mstore(add(input, 0x20), rs0)
            mstore(add(input, 0x40), rs1)
            mstore(add(input, 0x60), "\x04")
            mstore(add(input, 0x61), Q0)
            mstore(add(input, 0x81), Q1)
            let success := staticcall(gas(), 0x8001, input, 0xa1, out, 0x1)
            switch success
            case 0 {
                revert(0x0, 0x0)
            }
            default {
                result := mload(out)
            }
        }
    }
}


Vulnerability type: CWE-707|CWE-20
MEDIUM severity: Rounding error leads to additional assets taken from order taker. A rounding issue in the `AmountCalculator.getTakerAmount()` function can lead to excess assets being taken from the order taker.

Vulnerable code:
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../libraries/UncheckedAddress.sol";


contract AmountCalculator {
    using UncheckedAddress for address;

    // Floor maker amount
    function getMakerAmount(uint256 orderMakerAmount, uint256 orderTakerAmount, uint256 swapTakerAmount) external pure returns(uint256) {
        return swapTakerAmount * orderMakerAmount / orderTakerAmount;
    }

    // Ceil taker amount
    function getTakerAmount(uint256 orderMakerAmount, uint256 orderTakerAmount, uint256 swapMakerAmount) external pure returns(uint256) {
        return (swapMakerAmount * orderTakerAmount + orderMakerAmount - 1) / orderMakerAmount;
    }

    function arbitraryStaticCall(address target, bytes memory data) external view returns(uint256) {
        (bytes memory result) = target.uncheckedFunctionStaticCall(data, "AC: arbitraryStaticCall");
        return abi.decode(result, (uint256));
    }
}


Vulnerability type: CWE-682
HIGH severity: Missed addition to _totalSupply, or substraction from balances[this]. Precision loss during division should be handled appropriately.

Vulnerable code:
// Abstract contract for the full ERC 20 Token standard
// https://github.com/ethereum/EIPs/issues/20
pragma solidity ^0.4.8;

contract Token {
    /* This is a slight change to the ERC20 base standard.
    function totalSupply() constant returns (uint256 supply);
    is replaced with:
    uint256 public totalSupply;
    This automatically creates a getter function for the totalSupply.
    This is moved to the base contract since public getter functions are not
    currently recognised as an implementation of the matching abstract
    function by the compiler.
    */
    /// total amount of tokens
    uint256 public totalSupply;

    /// @param _owner The address from which the balance will be retrieved
    /// @return The balance
    function balanceOf(address _owner) constant returns (uint256 balance);

    /// @notice send `_value` token to `_to` from `msg.sender`
    /// @param _to The address of the recipient
    /// @param _value The amount of token to be transferred
    /// @return Whether the transfer was successful or not
    function transfer(address _to, uint256 _value) returns (bool success);

    /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
    /// @param _from The address of the sender
    /// @param _to The address of the recipient
    /// @param _value The amount of token to be transferred
    /// @return Whether the transfer was successful or not
    function transferFrom(address _from, address _to, uint256 _value) returns (bool success);

    /// @notice `msg.sender` approves `_spender` to spend `_value` tokens
    /// @param _spender The address of the account able to transfer the tokens
    /// @param _value The amount of tokens to be approved for transfer
    /// @return Whether the approval was successful or not
    function approve(address _spender, uint256 _value) returns (bool success);

    /// @param _owner The address of the account owning tokens
    /// @param _spender The address of the account able to transfer the tokens
    /// @return Amount of remaining tokens allowed to spent
    function allowance(address _owner, address _spender) constant returns (uint256 remaining);

    event Transfer(address indexed _from, address indexed _to, uint256 _value);
    event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}


Vulnerability type: CWE-682|CWE-1339
MEDIUM severity: LibSwap may pull tokens that are different from the specified asset. LibSwap.swap is responsible for doing swaps, but users can build a calldata to swap a different asset as specified.

Vulnerable code:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

import { LibAsset, IERC20 } from "./LibAsset.sol";
import { LibUtil } from "./LibUtil.sol";
import { InvalidContract } from "../Errors/GenericErrors.sol";

library LibSwap {
    error NoSwapFromZeroBalance();

    struct SwapData {
        address callTo;
        address approveTo;
        address sendingAssetId;
        address receivingAssetId;
        uint256 fromAmount;
        bytes callData;
    }

    event AssetSwapped(
        bytes32 transactionId,
        address dex,
        address fromAssetId,
        address toAssetId,
        uint256 fromAmount,
        uint256 toAmount,
        uint256 timestamp
    );

    function swap(bytes32 transactionId, SwapData calldata _swapData) internal {
        if (!LibAsset.isContract(_swapData.callTo)) revert InvalidContract();
        uint256 fromAmount = _swapData.fromAmount;
        if (fromAmount == 0) revert NoSwapFromZeroBalance();
        uint256 nativeValue = 0;
        address fromAssetId = _swapData.sendingAssetId;
        address toAssetId = _swapData.receivingAssetId;
        uint256 initialSendingAssetBalance = LibAsset.getOwnBalance(fromAssetId);
        uint256 initialReceivingAssetBalance = LibAsset.getOwnBalance(toAssetId);
        uint256 toDeposit = initialSendingAssetBalance < fromAmount ? fromAmount - initialSendingAssetBalance : 0;

        if (!LibAsset.isNativeAsset(fromAssetId)) {
            LibAsset.maxApproveERC20(IERC20(fromAssetId), _swapData.approveTo, fromAmount);
            if (toDeposit != 0) {
                LibAsset.transferFromERC20(fromAssetId, msg.sender, address(this), toDeposit);
            }
        } else {
            nativeValue = fromAmount;
        }

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory res) = _swapData.callTo.call{ value: nativeValue }(_swapData.callData);
        if (!success) {
            string memory reason = LibUtil.getRevertMsg(res);
            revert(reason);
        }

        emit AssetSwapped(
            transactionId,
            _swapData.callTo,
            _swapData.sendingAssetId,
            toAssetId,
            fromAmount,
            LibAsset.getOwnBalance(toAssetId) - initialReceivingAssetBalance,
            block.timestamp
        );
    }
}


Vulnerability type: CWE-284|CWE-285|CWE-732
HIGH severity: Possible underflow. Free balance from the report can be less than free balance from the previous era.

Vulnerable code:
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0;

import "./Owned.sol";

contract Ledger is Owned {
    mapping(bytes32 => uint256) public records;

    function record(bytes32 id) public onlyOwner {
        require(records[id] == 0, "already in ledger");
        records[id] = block.number;
    }

    function get(bytes32 id) public view returns (uint256) {
        return records[id];
    }
}


Vulnerability type: CWE-682|CWE-191
HIGH severity: Operators._hasFundableKeys returns true for operators that do not have fundable keys. Because _hasFundableKeys uses operator.stopped in the check, an operator without fundable keys be validated and return true.

Vulnerable code:
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "@openzeppelin/contracts/utils/Context.sol";

contract Operators is Context {
    // level 1: normal operator
    // level 2: rewards and feed manager
    // level 3: admin
    // level 4: owner
    mapping(address => uint256) operatorLevel;

    address public oldOwner;
    address public pendingOwner;

    modifier onlyOperator(uint256 level) {
        require(operatorLevel[_msgSender()] >= level, "invalid operator");
        _;
    }

    constructor() {
        operatorLevel[_msgSender()] = 4;
    }

    function setOperator(address op, uint256 level) external onlyOperator(4) {
        operatorLevel[op] = level;
    }

    function getOperatorLevel(address op) public view returns (uint256) {
        return operatorLevel[op];
    }

    function transferOwnership(address newOwner) external onlyOperator(4) {
        require(newOwner != address(0), "zero address");

        oldOwner = _msgSender();
        pendingOwner = newOwner;
    }

    function acceptOwnership() external {
        require(_msgSender() == pendingOwner, "not pendingOwner");

        operatorLevel[_msgSender()] = 4;
        operatorLevel[oldOwner] = 0;

        pendingOwner = address(0);
        oldOwner = address(0);
    }
}


Vulnerability type: CWE-697|CWE-1025
MEDIUM severity: Missing Storage Gap. Missing storage gaps in upgradeable contracts can lead to storage layout conflicts.

Vulnerable code:
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/Initializable.sol";
/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    function __Ownable_init() internal initializer {
        __Context_init_unchained();
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal initializer {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
    uint256[49] private __gap;
}


Vulnerability type: CWE-664|CWE-665|CWE-909
MEDIUM severity: Funds Lock. Users cannot claim tokens after the end date in TokenDistributor and PrivateSaleTokenDistributor contracts.

Vulnerable code:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol";

contract PrivateSaleTokenDistributor is Ownable2StepUpgradeable {
    IERC20 public token;
    uint256 public startTime;
    uint256 public endTime;
    uint256 public totalAmount;
    mapping (address beneficiary => uint256 claimAmount) public claimableAmounts;

    event CanClaim(address indexed beneficiary, uint256 amount);
    event HasClaimed(address indexed beneficiary, uint256 amount);
    event Swept(address receiver, uint256 amount);

    constructor(IERC20 _token, uint256 _startTime, uint256 _endTime) {
        _transferOwnership(_msgSender());

        token = _token;
        startTime = _startTime;
        endTime = _endTime;
    }

    function setClaimableAmounts(address[] calldata users, uint256[] calldata amounts) onlyOwner external {
        uint256 usersLength = users.length;
        require(usersLength == amounts.length, "setClaimableAmounts: User and amount list lengths must match!");
        
        uint256 totalClaimableAmount = 0;
        for (uint256 i = 0; i < usersLength; ) {
            address user = users[i];
            uint256 amount = amounts[i];
            claimableAmounts[user] = amount;
            emit CanClaim(user, amount);
            unchecked {
                totalClaimableAmount = totalClaimableAmount + amount;
                i += 1;
            }
        }

        require(token.balanceOf(address(this)) >= totalClaimableAmount, "Total claimable amount does not match");
        totalAmount = totalClaimableAmount;
    }

    function claim() external {
        require(block.timestamp >= startTime, "Tokens cannot be claimed yet");
        require(block.timestamp < endTime, "Distribution has ended");
        uint256 claimableAmount = claimableAmounts[_msgSender()];

        uint256 amount = token.balanceOf(address(this));
        require(amount > 0, "No tokens to claim");

        require(token.transfer(_msgSender(), claimableAmount), "Token transfer failed");
        claimableAmounts[_msgSender()] = 0;

        emit HasClaimed(_msgSender(), claimableAmount);
    }

    /**
    * @dev Transfer tokens from the contract to a given address.
    */
    function sweep() onlyOwner external {
        require(block.timestamp > endTime, "sweep: Cannot sweep before claim end time!");

        uint256 leftovers = token.balanceOf(address(this));
        require(leftovers != 0, "TokenDistributor: no leftovers");

        require(token.transfer(owner(), leftovers), "TokenDistributor: fail token transfer");

        emit Swept(owner(), leftovers);
    }
}

Vulnerability type: CWE-664
HIGH severity: Missing Check: Loss of Funds. No check for 0x0 address or non-existent pool address in _submitPools()

Vulnerable code:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract MetatimeToken is ERC20, ERC20Burnable, Ownable {
    struct Pool {
        bytes32 name;
        address addr;
        uint256 lockedAmount;
    }

    event PoolSubmitted(bytes32 name, address addr, uint256 lockedAmount);
    
    // total supply: 10_000_000_000 * 10 ** decimals()
    constructor(Pool[] memory _pools, uint256 _totalSupply) ERC20("Metatime", "MTC") {
        _submitPools(_pools, _totalSupply);
    }

    function _submitPools(Pool[] memory _pools, uint256 _totalSupply) internal returns(bool) {
        uint256 usersLength = _pools.length;
        
        uint256 totalLockedAmount = 0;
        for (uint256 i = 0; i < usersLength; ) {
            Pool memory pool = _pools[i];
            _mint(pool.addr, pool.lockedAmount);
            emit PoolSubmitted(pool.name, pool.addr, pool.lockedAmount);
            unchecked {
                totalLockedAmount = totalLockedAmount + pool.lockedAmount;
                i += 1;
            }
        }

        require(_totalSupply >= totalLockedAmount, "Total claimable amount does not match");

        return true;
    }
}

Vulnerability type: CWE-703|CWE-754