veth漏洞分析

博客讨论了一个智能合约的安全问题,其中changeExcluded函数允许外部调用者无限制地修改mapAddress_Excluded状态,这可能导致任意账户的token被转移。攻击者只需支付128veth就能改变地址状态,从而触发transferFrom函数转移大量token。此漏洞的存在暴露了合约资产的安全隐患。
摘要由CSDN通过智能技术生成

合约地址:0x75572098dc462F976127f59F8c97dFa291f81d8b
攻击交易:
https://etherscan.io/tx/0xdd1120a90ed4112b634266d6a244b93ca86785317bc75f0e170ab0cd97c65224

function transferFrom(address from, address to, uint value) public override returns (bool success) {
        if(!mapAddress_Excluded[msg.sender]){
            require(value <= _allowances[from][msg.sender], 'Must not send more than allowance');
            _allowances[from][msg.sender] -= value;
        }
        _transfer(from, to, value);
        return true;
    }
     function allowance(address owner, address spender) public view virtual override returns (uint256) {
        if(mapAddress_Excluded[spender]){
            return totalSupply;
        } else {
            return _allowances[owner][spender];
        }
    }

从函数中看mapAddress_Excluded拥有导出任意账户token的权利。而changeExcluded函数

function changeExcluded(address excluded) external {    
        if(!mapAddress_Excluded[excluded]){
            _transfer(msg.sender, address(this), mapEra_Emission[1]/16);                    // Pay fee of 128 Vether
            mapAddress_Excluded[excluded] = true;                                           // Add desired address
            excludedArray.push(excluded); excludedCount +=1;                                // Record details
            totalFees += mapEra_Emission[1]/16;                                             // Record fees
            mapAddress_BlockChange[excluded] = block.number;                                // Record time of change
        } else {
            _transfer(msg.sender, address(this), mapEra_Emission[1]/32);                    // Pay fee of 64 Vether
            mapAddress_Excluded[excluded] = false;                                          // Change desired address
            totalFees += mapEra_Emission[1]/32;                                             // Record fees
            mapAddress_BlockChange[excluded] = block.number;                                // Record time of change
        }               
    }

为external,可以从外部调用修改任意地址的mapAddress_Excluded状态,只要花费128veth。
通过修改mapAddress_Excluded后进行transferfrom操作即可将大量token转移并出售。


没搞懂如果是changeExcluded忘了权限控制,为什么要花费128veth来设置mapAddress_Excluded

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值