lienfinence 漏洞分析

合约代码:
https://github.com/LienFinance/idol/blob/master/contracts/BondMaker.sol

合约中函数reverseBondToETH可以提取任意数量eth到msg.sender(如果绕过for循环,即bondIDs.length为0),
通过在函数registerNewBondGroup传入空bondIDs,以及传入大于 _getBlockTimestampSec()的maturity,即可绕过_assertBondGroup()中所有的for循环验证,最后将函数registerNewBondGroup返回的bondGroupID以及想要的eth数量传入reverseBondToETH函数即可实现任意提取合约BondMaker中的eth。

 function reverseBondToETH(uint256 bondGroupID, uint256 amountE8)
        public
        override
        returns (bool)
    {
        BondGroup storage bondGroup = _bondGroupList[bondGroupID];
        bytes32[] storage bondIDs = bondGroup.bondIDs;
        require(
            _getBlockTimestampSec() < bondGroup.maturity,
            "the maturity has already expired"
        );
        bytes32 bondID;
        for (
            uint256 bondFnMapIndex = 0;
            bondFnMapIndex < bondIDs.length;
            bondFnMapIndex++
        ) {
            bondID = bondIDs[bondFnMapIndex];
            _burnBond(bondID, msg.sender, amountE8);
        }

        _transferETH(
            msg.sender,
            amountE8.mul(10**10),
            "system error: insufficient Ether balance"
        );

        emit LogReverseBondToETH(bondGroupID, msg.sender, amountE8.mul(10**10));

        return true;
    }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值